asp.net through Ajax UpdatePanel the scroll bar position changes (1/2)

Source: Internet
Author: User

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;
}
}

Home 1 2 last page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.