• 在刷新和提交页面后,保存滚动条的位置


    在PageLoad中调用下面的方法Position,注意StringBuilder属于System.Text命名空间

    private void Position()
    {
           
           RegisterHiddenField("ScrollPostion", "0");
           StringBuilder getPosition = new StringBuilder();
           getPosition.Append("<script language=javascript>");       
           getPosition.Append("function get(){");       
           getPosition.Append("document.forms[0].__SCROLLPOS.value = thebody.scrollTop;");
           getPosition.Append("}");       
           getPosition.Append("thebody.onscroll=saveScrollPosition;");      
           getPosition.Append("</script>");
           ClientScript.RegisterStartupScript(typeof(Page),"savePosition",getPosition.ToString());
           if (IsPostBack)
           {
                    StringBuilder setPosition = new StringBuilder();
                    setPosition.Append("<script language='javascript'>");
                    setPosition.Append("function setScrollPosition() {");
                    setPosition.Append(" thebody.scrollTop = " + Request["ScrollPostion"] + ";");
                    setPosition.Append("}");
                    setPosition.Append("thebody.onload=setScrollPosition;");
                    setPosition.Append("</script>");
                    RegisterStartupScript("setScroll", setPosition.ToString());
            }
    }

    转自:http://blog.163.com/hbsi_zhouwufeng/blog/static/4387253620071114423831/

  • 相关阅读:
    vscode task 与 linux shell编程小记
    Python并行计算专题
    分类任务评价指标(Accuracy / Precision / Recall / F1 / ROC / AUC)
    JAVA笔记 10.04
    MySQL5.7忘记密码 Linux
    MYSQL 获取最近多少天时间列表
    Volatile 关键字的原理和实现
    安装正常APP时被小米提醒是诈骗APP不允许安装的问题
    【瞎口胡】网络流基础
    题解 Luogu P4774 [NOI2018]屠龙勇士
  • 原文地址:https://www.cnblogs.com/zhangliang1988/p/2592733.html
Copyright © 2020-2023  润新知