Developing Matt

My Technical Journal

ajax scrolling and the asynchronous postback glitch

leave a comment »

A message from mitch:

Hey Guys,

I found something kind of weird while I was working on my website last night.  I have an image box inside of an ajax update panel.  This update panel gets refreshed by a timer that is set to fire every 300 milliseconds.  The problem that I found was that when you tried to scroll either horizontally or vertically it would do the asynchronous postback and return the scroll position to the top left of the page.  I found some javascript that fixes the problem and just wanted to pass it along in case anyone else runs into the same problem.

Just add this script to the page and it will not reposition the window.

 <script type=”text/javascript” language=”javascript”>Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandler);      function beginRequestHandler() {             Sys.WebForms.PageRequestManager.getInstance()._scrollPosition = null;       };</script> 

Thanks mitch!

Advertisements

Written by matt

March 19, 2008 at 8:00 am

Posted in javascript

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: