zoukankan      html  css  js  c++  java
  • Persist ScrollBar's Position After a PostBack

    这个page的参数可以去掉吗?

    Public Shared Sub PersistScrollPosition(ByVal page As Page)

            Dim saveScrollPosition As System.Text.StringBuilder = New System.Text.StringBuilder
            Dim setScrollPosition As System.Text.StringBuilder = New System.Text.StringBuilder

            page.RegisterHiddenField("__SCROLLPOS", "0")

            saveScrollPosition.Append("<script language='javascript'>")
            saveScrollPosition.Append("function saveScrollPosition() {")
            saveScrollPosition.Append(" document.forms[0].__SCROLLPOS.value = document.body.scrollTop;")
            saveScrollPosition.Append("}")
            saveScrollPosition.Append("document.body.onscroll=saveScrollPosition;")
            saveScrollPosition.Append("</script>")

            page.RegisterStartupScript("saveScroll", saveScrollPosition.ToString())

            If page.IsPostBack Then
                setScrollPosition.Append("<script language='javascript'>")
                setScrollPosition.Append("function setScrollPosition() {")
                setScrollPosition.Append(" document.body.scrollTop = " + page.Request("__SCROLLPOS") + ";")
                setScrollPosition.Append("}")
                setScrollPosition.Append("document.body.onload=setScrollPosition;")
                setScrollPosition.Append("</script>")

                page.RegisterStartupScript("setScroll", setScrollPosition.ToString())
            End If

        End Sub

  • 相关阅读:
    HBase写请求分析
    jquery+easyui主界面布局一例
    调试LD_PRELOAD注入的代码
    获取Oracle隐含參数信息
    Android组件系列----ContentProvider内容提供者【4】
    053第401题
    高速排序优化通过中位数优化
    较难理解的概念
    HDU 2546 饭卡(dp)
    HDU 2546 饭卡(dp)
  • 原文地址:https://www.cnblogs.com/Dream/p/22452.html
Copyright © 2011-2022 走看看