Resetting Scroll Position When Using

Posted by: Headlines, on 14 Nov 2007 | View original | Bookmarked: 0 time(s)

ASP.NET 2.0 added a number of built-in client-side enhancements that were missing from earlier versions. Many of these new features were detailed in an earlier article here on 4Guys, Client-Side Enhancements in ASP.NET 2.0. One of the least undocumented yet most helpful client-side enhancement, in my opinion, is MaintainScrollPositionOnPostback.

As its name implies, MaintainScrollPositionOnPostback ensures that the browser's scroll position is maintained across postbacks. Without MaintainScrollPositionOnPostback, when a user visits a web page that is "taller" than the browser window, they have to scroll down to see the content further down on the page. If the user then clicks on a Button or performs some other action that causes a postback, the browser reloads the page and, by default, returns to the home scroll position at the top of the page, requiring the user to scroll back down to the location they were viewing when the postback occurred. To have the user's scroll position remembered across postbacks, simply set MaintainScrollPositionOnPostback to True, which can be done on a page-by-page basis or applied to all pages by configuring this option through Web.config.

While MaintainScrollPositionOnPostback makes it easy to keep the visitor at the same scroll position across postbacks, there are scenarios where you may not want to return the user to their scroll position on postback, but instead return them to the top of the page. One such example is when displaying a pageable grid. When the user edits a record, you would want to keep them at the same scroll position, but when they change the page or delete a record, you may want to reset their scroll position to the top on postback. In this article we will examine a way to override the behavior of MaintainScrollPositionOnPostback on a case-by-case basis. Read on to learn more!
Read More >

Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 4447 | Hits: 71

Similar Posts

  • Custom Panels in Silverlight/WPF Part 4: Virtualization more
  • An annoying IE position: Relative and OverFlow-Y Bug more
  • TemplatePanel (aka MasterPage) for Silverlight more
  • Making Element Position Absolute with jQuery more
  • jQuery.position() on Invisible Elements fails more
  • Framework 3.5-SP1: WPF Performance Improvements more
  • A simple jQuery Client Centering Plugin more
  • Adding Mouse Wheel support in Silverlight. The easy way. more
  • jQuery.ui Sortable more
  • Getting absolute coordinates from a DOM element more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD