Monday, 5 September 2011

Maintain Scroll Position in ASP .net

Hi there are a Question to  maintain the position of the scrollbar on postbacks. In old .Net frameworks (ASP.NET 1.1 or earlier) it was a pain to maintain the position of the scrollbar when doing a postback operation you have to write hell lot of javascript code. This was especially true when you had a grid on the page and went to edit a specific row.  Instead of staying on the desired row, the page would reload and you would be placed back at the top and have to scroll down.
In ASP.NET 2.0 and onwards you can simply add the MaintainScrollPostionOnPostBack attribute to the Page directive:
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeFile="abc.aspx.cs" Inherits="WebApplication1.abc" %>

No comments:

Post a Comment