Maintain Scroll Position of EVERY Element on PostBacks

Update (5 Aug 2014):

I've uploaded the latest version of the script on github: https://github.com/hasheminezhad/scrollsaver

Introduction:

Normally when a page round trips to the server (or PostBack happens), the scroll position of the page resets and the user has to scroll back to the part where he/she was doing something. One of the nice little features in ASP.NET 2 is a page property called 'MaintainScrollPositionOnPostback' which as its name suggests, takes care of it in a way that just can't get any easier!
But the problem here is that, there may be other scroll bars in page (such as MultiLine TextBoxes, ListBoxes, ...) which there's no simple way to maintain their positions on postbacks. This situation gets even worse as we place UpdatePanels in the page and while there's [or seems to be] no postbacks, still scroll bars reset to zero on each request. As I couldn't find any SIMPLE solution for this, I tried to solve the problem myself and the result was a simple yet powerful script which I present it here.

Syndicate content