Resetting scroll position after completion of the partial update

When you use the UpdatePanel to implement partial updates,the scroll position will be maintained between the asynchronous post-backs.However,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.

2 Comments

Comments have been disabled for this content.