Tuesday, June 28, 2011
In this example, you will learn how to maintain scroll position in asp.net page after Postback is fired.
When Postback is fired, user returns on the top position of current page. User has to scroll down manually on last location of the page where he was working.
Page.MaintainScrollPositionOnPostBack Property is used to set or get the position of page after Postback is fired. Page.MaintainScrollPositionOnPostBack is supported in 2.O, 3.O, 3.5 and 4.O
Here’s an example
You can add below line on Page directive for a single page to maintain the previous scroll position when post back is fired.
<%@ Page MaintainScrollPositionOnPostback="true" %>
You can add below script on code behind for a single page to maintain the previous scroll position after post back is fired
Page.MaintainScrollPositionOnPostBack = true;
You can add below settings on Web.Config for all pages to maintain the previous scroll position when Postback is fired.
<pages maintainScrollPositionOnPostBack="true" />
- Page.MaintainScrollPositionOnPostBack will not work in ASP.NET 1.O and 1.1.
- Page.SmartNavigation property will work in ASP.NET 1.O and 1.1
- Page.SmartNavigation property is Obsolete in Frame work 2.O and higher