Hi all,
when I call the javascript method from code behind file of the same page it works fine.
But when i put the JavaScript method in the masterpage, there the problem occurs.
When I press the button1,
It scrolls to the new position and shows the alert message Script from master page.
When i press OK it returns back to the bottom ie. to the position of the button1
The master page coding is like this.
Why this happens?
How to rectify it.
Thanks in advance.
when I call the javascript method from code behind file of the same page it works fine.
Code:
ScriptManager.RegisterClientScriptBlock(this, Page.GetType(), "Scroll", "ScrollToPosition();", true);
When I press the button1,
It scrolls to the new position and shows the alert message Script from master page.
When i press OK it returns back to the bottom ie. to the position of the button1
The master page coding is like this.
Code:
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <script language="javascript" type="text/javascript"> function ScrollToPosition() { var pnlErrorMessage = document.getElementById('ctl00_ContentPlaceHolder1_pnlErrorMessage'); var x = pnlErrorMessage.offsetLeft; var y = pnlErrorMessage.offsetTop; alert("Script from master page"); window.scrollTo(x, y); } </script> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div>
How to rectify it.
Thanks in advance.
Comment