tags:

views:

429

answers:

2

Got a timer inside an updatepanel. It constantly refreshes (about every 2.5 seconds). If it refreshed while scrolling it sets the scroll position back to what it was berfore the partial update :(

I'm using ASP.NET 3.5 and MaintainScrollPositionOnPostback is set to false (even if set to true behaviour doesn't change).

No clue why this happens, but usability is annoying...

Kind regards, Sascha

+2  A: 

We had a similar problem where an asynchronous postback would reset the user to the top of a very long page. We resolved it after finding the following code at: http://forums.asp.net/t/1047815.aspx

We inserted the following javascript on our page after the ScriptManager on the page.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(beginRequest);

    function beginRequest() {
        prm._scrollPosition = null;
    }
</script>

This made it so the postback did not reset the users scroll position when the postback returned.

I'm not sure if this is exactly the problem that you are experiencing. You could also take a look at this post: http://stackoverflow.com/questions/616210/reset-scroll-position-after-async-postback-asp-net which discusses a more robust method of setting the scroll position after a postback occurs.

sgriffinusa
Got an error Sys.Webforms undefined. But on the link you posted, there's another snippet, (write your own empty scrollTo function). That did the trick. Must investigate why I get an error with your example ...
Sascha
May be one of the following: 1. Javascript appears before the ScriptManager http://bit.ly/8askn 2. Web.Config not setup for AJAX. http://bit.ly/ktZK2 3. EnablePartialRendering needs to be set to true on your ScriptManager. http://bit.ly/14Gsj Most likely culprit is #3.
sgriffinusa
Culprit was (1). Tried and after that read your post. Thanks.
Sascha
A: 

Thank You Very Much, it has solved my problem

Sumod