MaintainScrollPositionOnPostback不工作 - 如何调试?(Mainta

2019-11-04 09:10发布

我继承了一些网上商店项目( ASP.NET 3.5, WebformsVisual Studio 2008 PRO )。 在一个页面上我有MaintainScrollPositionOnPostback设置为true 。 当购物车(在主页加载的用户控制)是空的,那么asp.net不生成Javascript用于滚动位置所需的代码。 当我添加一些物品到购物车中,然后一切工作正常。

你能给我什么建议如何找到负责这一问题的部分代码? 我不必第三方分析器的访问。

Answer 1:

你使用的UpdatePanel在特定网页?

如果是,下面的文章也许会给你一些指导:

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

如果没有,这个可以帮助:

使用Javascript:维护页面滚动位置
下面是从文章的代码:

// 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>

希望这些链接可以帮助之一!



文章来源: MaintainScrollPositionOnPostback is not working - how to debug?