How do I locate a page when I click a Web control to raise a page refresh? (Do not use smart navigation)

Source: Internet
Author: User
web| Control | refresh | Page 1 function (refer to other netizens, make changes)


#Region "Prevent page scrolling"
Private Function retainscrollposition ()
Dim savescrollposition as StringBuilder = New StringBuilder
Dim setscrollposition as StringBuilder = New StringBuilder

RegisterHiddenField ("__scrollpos", "0")

Savescrollposition.append ("<script language= ' JavaScript ' >")
Savescrollposition.append ("function savescrollposition () {")
Savescrollposition.append ("document.forms[0].__scrollpos.value = Mybody.scrolltop;")
Savescrollposition.append ("}")
Savescrollposition.append ("mybody.onscroll=savescrollposition;")
Savescrollposition.append ("</script>")

RegisterStartupScript ("Savescroll", Savescrollposition.tostring ())

If (Page.IsPostBack) Then
Setscrollposition.append ("<script language= ' JavaScript ' >")
Setscrollposition.append ("function setscrollposition () {")
Setscrollposition.append ("Mybody.scrolltop =" & Request ("__scrollpos") & ";"
Setscrollposition.append ("}")
Setscrollposition.append ("mybody.onload=setscrollposition;")
Setscrollposition.append ("</script>")

RegisterStartupScript ("Setscroll", Setscrollposition.tostring ())
End If
End Function
#End Region


2. Call


Call Retainscrollposition () in the Page_Load event


3. Other


Name the <body> id "mybody"




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.