加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – 列表框在autopostback上滚动到顶部

发布时间:2020-12-16 09:49:28 所属栏目:asp.Net 来源:网络整理
导读:为什么在启动autopostback时,asp.net列表框总是在选择项目时滚动到顶部?我怎样才能防止这种情况发生? 解决方法 我在 javascript中添加了以下jquery来解决问题.我不记得我在哪里找到了解决方案,但在这里.只需添加目标控件的位置 – $get(‘YourDiv_YourPane
为什么在启动autopostback时,asp.net列表框总是在选择项目时滚动到顶部?我怎样才能防止这种情况发生?

解决方法

我在 javascript中添加了以下jquery来解决问题.我不记得我在哪里找到了解决方案,但在这里.只需添加目标控件的位置 – $get(‘YourDiv_YourPanel’).

<script type="text/javascript">
    //Maintain scroll position in given element or control
    var xInputPanel,yInputPanel;
    var xProductPanel,yProductPanel;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender,args) {
        yInputPanel = $get('MainContent_InputPanel').scrollTop;
        yProductPanel = $get('MainContent_ProductPanel').scrollTop;
    }
    function EndRequestHandler(sender,args) {
        $get('MainContent_InputPanel').scrollTop = yInputPanel;
        $get('MainContent_ProductPanel').scrollTop = yProductPanel;
    }
</script>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读