How to maintain the position of the scrollbar on postbacks with ASP.NET 2.0

October 2nd, 2007 by Joe

In ASP.NET 1.1 it was a pain to maintain the position of the scrollbar when doing a postback operation.

In ASP.NET 2.0 you can simply add the MaintainScrollPostionOnPostBack attribute to the Page directive of any specific page:

<% Page Language=”C#” … MaintainScrollPositionOnPostback=”true” %>

If you would like to apply this behavior to your entire site simply modify the &lt;pages /> entry of your <system.web /> section in your web.config file like so:

<pages maintainScrollPositionOnPostBack=”true”>

Posted in ASP.NET, Joe, Web Development, technology

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Greener Living thru Technology

JoeLevi.com is the personal web log of Joe Levi -- an ASP.NET Web Developer by trade and by hobby. Joe's love of technology isn't just limited to the web, he's also interested in green and environmentally friendly technology and technological solutions. If it has to do with technology, improving the quality of life, geek humor, tech politics, self-defense, environmental stewardship, or anything related, you'll probably find it at www.JoeLevi.com.

Site statistics:
Average: ~1.3 P/V; Visits: ~3,000; Pageviews: ~3,600; Google PR: 4; TechnoratiAuthority: 17; Technorati Rank: 487,964