Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Normally, if the updatepanel posts back, the item will scroll back to the top because it has been reloaded. What you need to do is “remember” where the item was scrolled to and jump back to there after the postback.writting the following script after the ScriptManager on page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item move but the update panel having the timer is not working the timer dosnt get started or updated

can anyone provide the solution for it

<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('scrollDiv').scrollLeft;
yPos = $get('scrollDiv').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('scrollDiv').scrollLeft = xPos;
$get('scrollDiv').scrollTop = yPos;
}
</script>


Plz get some needfull solution fot the same.
Posted

1 solution

<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server" scriptmode="Release" xmlns:asp="#unknown">
<script type="text/javascript">
// It is important to place this JavaScript code after ScriptManager1
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();

function BeginRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
// Get X and Y positions of scrollbar before the partial postback
xPos = $get('<%=Panel1.ClientID%>').scrollLeft;
yPos = $get('<%=Panel1.ClientID%>').scrollTop;
}
}

function EndRequestHandler(sender, args) {
if ($get('<%=Panel1.ClientID%>') != null) {
// Set X and Y positions back to the scrollbar
// after partial postback
$get('<%=Panel1.ClientID%>').scrollLeft = xPos;
$get('<%=Panel1.ClientID%>').scrollTop = yPos;
}
}

prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>

<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
<contenttemplate>
<asp:panel id="Panel1" runat="server" height="300">
<%-- Some stuff which would cause a partial postback goes here --%>




</form>
 
Share this answer
 
Comments
Member 10227107 23-Apr-14 2:08am    
thanks for this code.
Sharath.Mitte 25-Apr-14 7:43am    
its good..but in my case i have a master page,am using script manager in master, and i want to do this code in child page of master..how can i go for that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900