maintaining the scroll position of the div after partial page post back

prem07it50-22307
Posted by prem07it50-22307 under JavaScript category on | Points: 40 | Views : 1829
//JavaScript functions for maintaining the scroll position of the div after partial page post back
var xPos,yPos;
var prm=Sys.WebForms.PageRequestManager.getInstance();

function BeginRequestHandler(sender,args)
{
if(document.getElementById('<%=scrll.ClientID%>')!=null) //Scrll is the id of the div tag to which we apply this javascript
{
xPos=document.getElementById('<%=scrll.ClientID%>').scrollLeft;
yPos=document.getElementById('<%=scrll.ClientID%>').scrollTop;
}
}

function EndRequestHandler(sender,args)
{
if(document.getElementById('<%=scrll.ClientID%>')!=null)
{
document.getElementById('<%=scrll.ClientID%>').scrollLeft=xPos;
document.getElementById('<%=scrll.ClientID%>').scrollTop=yPos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);

Comments or Responses

Login to post response