MaintainScrollPositionOnPostback not working - how to debug?

I inherited a web store project ( ASP.NET 3.5, Webforms , Visual Studio 2008 PRO ). On one page, I have MaintainScrollPositionOnPostback set to true . When the shopping cart (user control uploaded to the main page) is empty, then asp.net does not generate the Javascript code needed for the scroll position. When I add some items to the basket, everything works fine.

Can you give me some advice on how to find the part of the code that is responsible for this problem? I do not have access to third-party profilers.

0
source share
1 answer

Are you using UpdatePanels on this particular page?

If so, the following article may give you some direction:

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

If No, this may help:

Javascript: maintaining page scroll position
Here is the code from this 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 helps!

0
source

Source: https://habr.com/ru/post/897193/


All Articles