So in my case I have to maintain a scroll position of a child page after async post back of user control list box.
I have tried:
Code
MaintainScrollPositionOnPostback="true" var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = document.getElementById("<%=UpdatePanel1.ClientID %>").scrollLeft;
yPos = document.getElementById("<%=UpdatePanel1.ClientID %>").scrollTop;
}
function EndRequestHandler(sender, args) {
document.getElementById("<%=UpdatePanel1.ClientID %>").scrollLeft = xPos;
document.getElementById("<%=UpdatePanel1.ClientID %>").scrollTop = yPos;
}
For panel and for div and update panel..these all are fails completely, why because if child page is getting post back means the related master pages also post backed..but I don't know how to maintain the scroll position..
please Try to help me as soon as possible..
Thanks guys
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Apr 28, 2014, 9:12 PM EDT
Sharath Quad77 reputationPosted Apr 29, 2014, 11:27 PM EDT
Sharath Quad77 reputationPosted May 12, 2014, 3:03 AM EDT
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = document.getElementById("<%=Panel1.ClientID %>").scrollLeft;
yPos = document.getElementById("<%=Panel1.ClientID %>").scrollTop;
var h = document.getElementById("<%=hid.ClientID %>");
h.value = xPos.toString() + "_" + yPos.toString();
}
function EndRequestHandler(sender, args) {
var val = document.getElementById("<%=hid.ClientID %>").value.split('_');
xPos = parseFloat(val[0]);
yPos = parseFloat(val[1]);
document.getElementById("<%=Panel1.ClientID %>").scrollLeft = xPos;
document.getElementById("<%=Panel1.ClientID %>").scrollTop = yPos;
}