I had a requirement today for an ASP.NET page to jump to the same part of the page once a form was submitted via a postback.
Qudos to my fellow developer Andy Howell for leaping in and pointing out that functionality was already in ASP.NET 2.0 and above, so there would be no need for me to write any funky JavaScript.
You need to set MaintainScrollPositionOnPostback to true. I did this in the Page
tag on the ASP.NET page.
<%@ Page MaintainScrollPositionOnPostback="true" %>
Although I’ve not tested it yet, you should also be able to set it globally in the web.config file in the pages section.
<pages maintainScrollPositionOnPostBack="true" />
Or programmatically in the code behind.
System.Web.UI.Page.MaintainScrollPositionOnPostBack = true;
For more information on this, see the MSDN page for System.Web.UI.Page.MaintainScrollPositionOnPostBack.