Last post Aug 12, 2013 01:01 AM by philos
Aug 11, 2012 01:47 AM|philos|LINK
i have been trying to find a good way to maintain the scroll position on a page after an UpdatePanel async postback. i tried a couple options:
Page.MaintainScrollPositionOnPostBack = True
and the web.config method:
<pages smartNavigation="true" maintainScrollPositionOnPostBack="true" ></pages>
but neither works.
i have a GridView inside the UpdatePanel and after every Submit button click the screen flashes and jumps to the top of the page. i then have to scroll back down to see the results of the query.
has anyone found a way to save the location of the page in codebehind, then reload the scroll position to where original submit query was initiated on the page?
Aug 11, 2012 05:25 AM|ganesh.rane|LINK
Aug 11, 2012 06:06 AM|philos|LINK
Aug 11, 2012 06:15 AM|ajvadrahman|LINK
place ahidden input on your page
<input runat="server" type="hidden" id="hdnScrollTop" value="" />
suppose your update panel is on a div with id DataDiv call a script from the div
and the script is
var div = document.getElementById('DataDiv');
var input = document.getElementById("hdnScrollTop");
and now add anothe script to get the position on postback
register the script on page load
ClientScript.RegisterStartupScript(this.GetType(), "ScrolPosition", "<script>ScrolPosition('DataDiv','ctl00_cphMain_hdnScrollTop');</script>");
"ctl00_cphMain_hdnScrollTop" is the hidden feild running id make the corresponding changes in your id and run it safely
Aug 11, 2012 06:38 AM|philos|LINK
Aug 13, 2012 03:31 AM|chetan.sarode|LINK
Usually People loves to maintain the scroll postiion. But requirment is reverse, Here is the trick, create an script tag after the scriptmanager and put the following lines:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm._scrollPosition = null;
Aug 13, 2012 07:24 AM|teguhyuliantos|LINK
Here the additional reference for you about how to maintain scroll position with update panel :
Aug 17, 2012 01:24 AM|philos|LINK
result: the page posts to the top of the page after a partial postback.
the page posts to the top of the page after a partial postback.
these two links are the same solution, located at different sites. the page posts to the top of the page after a partial postback.
the best option so far is to simply use the web.config option. the position on the page is maintained after a partial postback, however, the page flashes (flickers) badly after the asynchronous postback. if i can find a fix for the flicker, i will have
a complete solution. thanks to everyone, but still looking.
Aug 12, 2013 01:01 AM|philos|LINK
to put a close on this thread, i used an asp:UpdatePanel to remove the page flicker. for me, the web.config code was the best solution to maintain scroll position.
hope it helps someone.