问题描述
我继承了一些网络商店项目( ASP.NET
3.5, Webforms
, Visual Studio 2008 PRO
)。
在一个页面上,我将 MaintainScrollPositionOnPostback
设置为 true
。
当购物车(在母版页中加载的用户控件)为空时,asp.net不会生成滚动位置所需的代码 Javascript
。当我将一些项目添加到购物车中时,一切都可以正常工作。
I inherited some web shop project (ASP.NET
3.5, Webforms
, Visual Studio 2008 PRO
).On one page I have MaintainScrollPositionOnPostback
set to true
.When shopping cart (user control loaded in master page) is empty, then asp.net is not generating Javascript
code required for scroll position. When I add some items to the cart, then everything works fine.
您能否给我任何建议,如何找到负责此问题的部分代码?
我没有访问第三方剖析器。
Can you give me any advice how to find part of the code which is responsible for this issue?I don't have an access to the 3rd party profilers.
推荐答案
您是否在该特定页面中使用UpdatePanels ?
Are you utilizing UpdatePanels in that specific page?
如果是,以下文章可能会给您一些方向:
If Yes, following article may give you some direction:
如果否,可以协助:
Javascript:维护页面滚动位置
这是这篇文章的代码:
Javascript: Maintaining Page Scroll Position
Here is the code from that article:
// 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>
希望其中一个链接帮助!
Hope one of these links help!
这篇关于MaintainScrollPositionOnPostback不工作 - 如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!