Asp.net changes the position of the scroll bar after Ajax UpdatePanel is returned (1/2)

Source: Internet
Author: User

Use a hidden control to save the current scorll value. After return, reset scroll Based on the value of scroll.


1. First, use the onscroll event to save the scorll value and use hiddenfield to record the scroll value.
Copy the 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 an onscroll event to save the scroll value of the current control.
Copy the Code as follows:
Function funsavescroll (sender ){
// Obtain the hidden Control
Var vscroll = $ get ('ctl00 _ contentplaceholder1_hflvscroll ');
If (vscroll! = Null ){
// Set the value of the hidden control to scorll.
Vscroll. value = sender. scrolltop;
}
}

 

Code
Copy the Code as follows:
// 3. process the scorll value in the page load completion event
Var prm = sys. webforms. pagerequestmanager. getinstance ();
// Set the loading completion event
Prm. add_pageloaded (pageloaded );

// Reset the scroll value of the control after loading.
Function pageloaded (sender, args ){
// Obtain the control for setting the scroll value.
Var vdiv = $ get ("lv_content ");
If (vdiv! = Null ){
// Obtain the hidden Control
Var vscrollvalue = $ get ("ctl00_contentplaceholder1_hflvscroll ");
// Set the scroll value of the control
Vdiv. scrolltop = vscrollvalue. value;
}
} 1 2

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.