devxlogo

Preserve Browser Scroll Position After a Postback

Preserve Browser Scroll Position After a Postback

For large web pages, you often want to maintain the user’s current scroll position after a postback. To do that, use one of the following methods:

  • In Web.config, in the section, add the Boolean attribute maintainScrollPositionOnPostBack="true". This will maintain the scroll positions for all the web site pages.
  • In the page declaration, add . Doing so maintains the scroll position for that page only.
  • From code behind, you can include System.Web.UI.Page.MaintainScrollPositionOnPostBack = true;. That’s the equivalent of using the page declaration (it maintains the scroll position for only the altered page).

devx-admin

Share the Post: