【问题标题】:MaintainScrollPositionOnPostback is not working - how to debug?MaintainScrollPositionOnPostback 不起作用 - 如何调试?
【发布时间】:2011-05-25 18:50:02
【问题描述】:

我继承了一些网店项目(ASP.NET3.5、WebformsVisual Studio 2008 PRO)。 在一页上,我将MaintainScrollPositionOnPostback 设置为true。 当购物车(母版页中加载的用户控件)为空时,asp.net 不会生成滚动位置所需的Javascript 代码。当我将一些商品添加到购物车时,一切正常。

您能给我任何建议如何找到导致此问题的部分代码吗? 我无权访问第 3 方分析器。

【问题讨论】:

    标签: asp.net debugging webforms


    【解决方案1】:

    您是否在该特定页面中使用 UpdatePanel?

    如果是,以下文章可能会给您一些指导:

    http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/

    如果否,这可能会有所帮助:

    Javascript: Maintaining Page Scroll Position
    这是那篇文章的代码:

    // function saves scroll position
    function fScroll(val)
    {
        var hidScroll = document.getElementById('hidScroll');
        hidScroll.value = val.scrollTop;
    }
    
    // function moves scroll position to saved value
    function fScrollMove(what)
    {
        var hidScroll = document.getElementById('hidScroll');
        document.getElementById(what).scrollTop = hidScroll.value;
    }
    </script>
    </head>
    
    <body onload="fScrollMove('div_scroll');" onunload="document.forms(0).submit()";>
    <form>
    <input type="text" id="hidScroll" name="a">< /br>
    <div id="div_scroll" onscroll="fScroll(this);" 
    style="overflow:auto;height:100px;width:100px;">
    
    .. VERY LONG TEXT GOES HERE
    
    </div>
    </form>
    </body>
    </html>
    

    希望这些链接之一有所帮助!

    【讨论】:

      猜你喜欢
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-06
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      相关资源
      最近更新 更多