Now just add the below JavaScript code to the relevant section of your Web Page.
- <script type="text/javascript">
- var xPos, yPos, needScroll;
- var prm = Sys.WebForms.PageRequestManager.getInstance();
- prm.add_beginRequest(BeginRequestHandler);
- prm.add_pageLoaded(EndRequestHandler)
- function BeginRequestHandler(sender, args) {
- xPos = 0;
- yPos = window.pageYOffset || document.documentElement.scrollTop;
- }
- function EndRequestHandler(sender, args) {
- if (needScroll) {
- window.setTimeout("window.scrollTo(" + xPos + "," + yPos + ")", 100);
- }
- }
- </script>
After adding the above code at page script Tag on your code behind you need to add the below code at your .cs page to call the Javascript function after page completes its rendering after postback.
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ScrollTo", "var needScroll = true;", true);
No comments:
Post a Comment