问题
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.
回答1:
Are you utilizing UpdatePanels in that specific page?
If Yes, following article may give you some direction:
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
If No, this one may assist:
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!
来源:https://stackoverflow.com/questions/4448038/maintainscrollpositiononpostback-is-not-working-how-to-debug