Anas Ghanem

ASP.NET from the middle east

Syndication

Sponsors

News


    Subscribe in a reader
Resetting scroll position after partial update Completed.

 When you use the UpdatePanel to implement partial updates,the scroll position will be maintained between the asynchronous post backs;But you may need to reset the scroll position after the partial update completed ( after receiving the response).

To do that you can handle the PageRequestManager endrequest event  and use window.scrollTo JavaScript method.

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { window.scrollTo(0, 0); });
        </script>

Note: make sure to place the scrip inside the Form element , otherwise you will get exceptions like Sys is not defined.


Published Friday, January 02, 2009 12:56 AM by anas
Filed under: ,

Comments

# re: Resetting scroll position after partial update Completed.@ Monday, January 05, 2009 1:49 AM

Good tip!

# re: Resetting scroll position after partial update Completed.@ Monday, February 02, 2009 2:35 PM

This code snippet is something which we can use in our organization. Well done.

Leave a Comment

(required) 
(required) 
(optional)
(required)