ASP.NET FAQ - maintain page scroll position after a page postback
I found the answer to an ASP.NET question that I've been asked literally about 10 times.
How do you maintain page scroll position after a postback?
Say you've got some really long page, perhaps with some huge Control -- like, say, a huge, edit-enabled GridView. Someone clicks a link halfway down that page (like, say, the "Edit" link on one of the later entries in that huge GridView). It generates a postback, and the page get refreshed to its *top* instead of half-way down.
If you want, instead, to maintain the page scroll on a postback, just set the MaintainScrollPositionOnPostback property on the Page. You can do this declaratively (in your aspx Page directive) like so:
<%
@ Page MaintainScrollPositionOnPostback="true" ... %>
If that's too heavy-handed a solution (i.e. you don't want to maintain scroll position for all postbacks), you can use the solution foundĀ on this page.