作者:乐韵答题 | 2023-09-08 20:49
1> TomHastjarja..:
var xPos, yPos; // global variable declaration
var prm = Sys.WebForms.PageRequestManager.getInstance(); // Some webforms javascript manager
/*
* Begin function with 2 arguments
*/
function BeginRequestHandler(sender, args) {
// check if the element generated by .net with id 'lstAuctions.ClientID' exists
if ($get('<%=lstAuctions.ClientID %>') != null) {
// get its scroll left and top position and
// assign it to the global variables
xPos = $get('<%=lstAuctions.ClientID %>').scrollLeft;
yPos = $get('<%=lstAuctions.ClientID %>').scrollTop;
}
}
/*
* this method gets executed last, it uses the
* already set global variables to assign the old scrollpositions again
*/
function EndRequestHandler(sender, args) {
if ($get('<%=lstAuctions.ClientID %>') != null) {
// assign the previous scroll positions
$get('<%=lstAuctions.ClientID %>').scrollLeft = xPos;
$get('<%=lstAuctions.ClientID %>').scrollTop = yPos;
}
}
// first function gets executed on the beginning of a request
prm.add_beginRequest(BeginRequestHandler);
// second function gets executed on the end of the request
prm.add_endRequest(EndRequestHandler);