In this example i'm explaining different methods of Maintaining Scroll Position On/After Postback In Asp.Net 2.0,3.5,4.0 Web pages or Applications.
Method 1 .
Write below mention directive in page directive section of html source of aspx page to maintain scroll position of only one page or selected pages rather then whole web application.
Method 2.
To maintain scroll position programmatically use code mentione below.
Method3.
To maintain scroll position application wide or for all pages of web application we can write below mentioned code in pages section of web.config file so that we don't need to add page directive in each and every page.
Hope this helps.
Method 1 .
Write below mention directive in page directive section of html source of aspx page to maintain scroll position of only one page or selected pages rather then whole web application.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
MaintainScrollPositionOnPostback="true" Inherits="_Default" %>
Method 2.
To maintain scroll position programmatically use code mentione below.
System.Web.UI.Page.MaintainScrollPositionOnPostBack = true;
Method3.
To maintain scroll position application wide or for all pages of web application we can write below mentioned code in pages section of web.config file so that we don't need to add page directive in each and every page.
<pages maintainScrollPositionOnPostBack="true">
Hope this helps.
If you like this post than join us or share
7 comments:
hi just registered ,, tina
this does not work at all
@Avobe: What's not workingfor you ?, what error you are getting ?
it does not work, when page reload, it goes to top of the page for IE8.
Doesn't work in Chrome - it may be only for IE browser.
@Sandra: Yes this method doesn't work in Google Chrome.
Read Asp.Net Maintain ScrollPosition OnPostBack In Chrome to know how to maintain scroll position on postback in Google Chrome browser.
Add it to an update panel inside of a tab container, on an aspx page with a master page. Then you are doing something!!! lol
Post a Comment