Solved

MaintainScrollPositionOnPostback doesn't work in Ajax postback

Posted on 2008-10-22
3
1,497 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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