Posted by: Cirilo Meggiolaro | 04/8/2009

Tip of the day #176 – Scrolling to the same position on the page after postback

Imagine the scenario: Your application has a large web form that you need to scroll down to see all its content. At the bottom there is a button that posts the page to the server. After the postback, the page is displayed on the top. What if you want to scroll down until the same position you were before the post?

How to…

Define at the page level

To define for a specific page only, you may add the property MaintainScrollPositionOnPostback to the page directive and set its value to true:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”Default.aspx.cs” Inherits=”Tip176._Default” MaintainScrollPositionOnPostback=”true” %>

Define at the application level

Open the web.config file of your application and add the attribute maintainScrollPositionOnPostback to the pages section and set its value to true. Pay attention to the fact that the name is case sensitive:

<pages maintainScrollPositionOnPostBack=true></pages>


  1. I hope see more ASP.NET tips here! Yesterday I almost sent you an e-mail asking for ASP.NET tips… What a coincidence!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: