Maintain Scroll Position on Postback in ASP.NET

An easy way to maintain the current scroll position across postbacks in ASP.NET is to use the MaintainScrollPositionOnPostback page directive attribute. This is useful if you are working on big pages where scrolling is necessary, and works in most common browsers.

There are three ways of applying the property to a web page.

  1. You can set it programmatically

    Page.MaintainScrollPositionOnPostBack = true;
  2. In the page declaration

    <%@ Page MaintainScrollPositionOnPostback=”true” %>
  3. Or in the web.configs <system.web> section.

    <pages maintainScrollPositionOnPostBack=”true” />

Leave a Reply