ReScroller 1.0 for .NET

This code is an ASP.NET (VB) custom server control to maintain the browser's scroll position after postback. Unlike the .NET/IE SmartNavigation feature, it works with all browsers and does not produce weird quirks.

1. To use this control, you must confirm which web standard you are targeting. For XHTML, you are ready to compile. If you are using HTML4 or anything else, you will need to change line 17 to use the correct document object. XHTML uses documentElement and older standards such as HTML4 use body. (I could have automated the selection, but I only use XHTML so not an issue. If you want, change the javascript to test for the documentElement and use it otherwise use body).

2. Change the namespace if you wish to bundle it into one of you existing control assemblies, otherwise leave at as is, but you will need to register it on the page (and in Visual Studio).

3. Compile the control to an assembly / dll.

4. Register the assembly in your page (if you used my namespace):

<%@ Register TagPrefix="HB" NameSpace="Bean.Controls" Assembly="ReScroller" %>

5. Insert this tag inside the form tag of your page:

<HB:ReScroller id="rescroller" runat="server" />

6. That's It! It will automatically work now.


Inserting SmartNavigation="True" into the page declaration of your aspx page will provide similar functionality to this control, but it has some major failings. I got very excited the first time I used it, but then after a while I started to notice a lot of badness:

1. Only suppose to work with IE. I've heard it may work with some other very new browsers, but this is unconfirmed.
2. It breaks the .focus() method.
3. It often produces very weird issues: javascript timer running very fast, style sheets not loading, page deforming, etc.


Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, with only one condition: References to the original author in the comments of the source code/scripts must remain in place. No other conditions or restrictions are made.
This software is provided "as is" without express or implied warranty.

If you improve this code, please send me a copy! Thanks!
Donate via PayPal

Hunter Beanland
hunter @

Version History
1.0 Original.