Thursday, March 25, 2004
One of the things I hate about the joy of postbacks is losing my scroll position. On a page that's a bit longer than the window, if I have an auto-postback combobox (for example), the user selects an item, the page posts back, and poof! they're back at the top of the page.
On a corporate intranet the post back is nice and fast, and many times the user has no clue that it happened.... Except for the fact that the page just "jumped" back to the top.
Because of this I (as many people) write my controls to re-position, or I have page logic to re-position after a postback. There are articles on CodeProject with controls for keeping the scroll position, one on DotNetJunkies that isn't quite so pre-packaged, but still good, and several tutorials. The problem then is that the behavior is coded in everywhere, or the control must be included on each page, or the page must be derived from something other than the Page class, or something else.. I wanted a fire and forget solution.
The nice thing about this (to me) is that three lines in your web.config instantly gives you scroll position retention across postbacks on every page in your application. No muss, and not a whole lot of fuss.