How to maintain scroll position on autopostback?

There are a few ways I have used to set maintainScrollPositionOnPostBack. Have you tried more than one? Can you describe what is triggering the postback and which browsers you have tested? Are you using a master page?

  1. You can set Page.MaintainScrollPositionOnPostBack = true; in the code behind on page load.
  2. You can add it to the page declaration <%@ Page MaintainScrollPositionOnPostback="true" %>
  3. You can add it in the web config file <pages maintainScrollPositionOnPostBack="true" />

You can set .Focus() onto a specific server control when your page posts back.


I've recently looked for this as well. Came up with a load of Javascript to be inserted until I found the following:

At the top of your .aspx codefile, insert the following:

 MaintainScrollPositionOnPostback="true"

so the very first sentence in your .aspx starts

<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeBehind="Default.aspx.cs"

This works just fine for me without having to add any other code for keeping scrollbar positions using updatepanels