Solved

MaintainScrollPositionOnPostback doesn't work in Ajax postback

Posted on 2008-10-22
3
1,471 Views
Last Modified: 2012-05-05
I have a none Ajax aspx page which worked with MaintainScrollPositionOnPostback where after a postback, the page came back at the same scroll position. When I converted the page to use Ajax, the page always scrolls to the top.

Is there a way to maintain scroll position after an asynchronous postback?
0
Comment
Question by:jentel2
3 Comments
 
LVL 10

Accepted Solution

by:
Bane83 earned 500 total points
Comment Utility
Add this to the end of your page.
<script type="text/javascript">

	var scrollTop;
 

	Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

	Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
 

	function BeginRequestHandler(sender, args) 

	{

		scrollTop = document.body.scrollTop;

	}
 

	function EndRequestHandler(sender, args)

	{

		setTimeout(EndRequestHandler1, 0);

	} 

	

	function EndRequestHandler1(sender, args)

	{

		document.body.scrollTop = scrollTop;

	} 

	

</script>

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now