Solved

MaintainScrollPositionOnPostback doesn't work in Ajax postback

Posted on 2008-10-22
3
1,505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
Bane83 earned 500 total points
ID: 22785963
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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