There are 3 ways to maintain the page scroll position after postbacks in ASP.NET 2.0:
- In the page declaration:
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>
- Programmatically, with the "MaintainScrollPositionOnPostback" (default = false) property for the page:
protected void Page_Load(object sender, EventArgs e)
{
MaintainScrollPositionOnPostBack = true;
}
- Configuring the "maintainScrollPositionOnPostBack" attribute for the "pages" element in the web.config:
<system.web>
<pages maintainScrollPositionOnPostBack="true" />
</system.web>
Methods 1 and 2: the scroll position will be maintained only for the current page.
Method 3: the scroll position will be maintained for all the web site pages.
HTH