Saves the current SCORLL value with a hidden control. After the return, the scroll is reset according to the scroll value.
1, first use onscroll event to save Scorll value, and HiddenField record scroll value
Copy code code as follows:
<div id= "lv_content" class= "unify_content" style= "padding-left:0"; height:455px "Onscroll=" setscrollposition (this) >
</div>
<asp Tutorial: HiddenField id= "Hiddenfieldscroll" runat= "Server"/>
Code
2, write Onscroll event, mainly used to save the current control scroll value
Copy code code as follows:
function Funsavescroll (sender) {
Get hidden controls
var vscroll = $get (' Ctl00_contentplaceholder1_hflvscroll ');
if (VScroll!= null) {
Set the value of a hidden control to Scorll value
Vscroll.value = Sender.scrolltop;
}
}
Code
Copy code code as follows:
3, in the page load completion event processing SCORLL value
var PRM = sys.webforms.pagerequestmanager.getinstance ();
Setting Load Completion Events
Prm.add_pageloaded (pageloaded);
Load completes reset control's scroll value
function pageloaded (sender, args) {
Get the control to set the scroll value
var vdiv = $get ("lv_content");
if (vdiv!= null) {
Get hidden controls
var vscrollvalue = $get ("Ctl00_contentplaceholder1_hflvscroll");
Set the scroll value of a control
Vdiv.scrolltop = Vscrollvalue.value;
}
}