jumbojs
jumbojs

Reputation: 4868

UpdatePanel contol and moving to top of page

I have an asp.net page that is using an UpdatePanel control. When you're on the page and you click the continue button, the page does a partial refresh and you're left in the same scroll position you were before the refresh. How do I ensure that on partial refreshes with the UpdatePanel control that you return to the top of the page.

thanks

Upvotes: 0

Views: 2318

Answers (2)

Dug
Dug

Reputation: 835

Here is how you do it using jquery and the updatepanel

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

   pageRequestManager.add_endRequest(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
    });
</script>

Upvotes: 2

Matt Hamsmith
Matt Hamsmith

Reputation: 4036

There is a javascript call to move the scroll to the top of the page:

window.scrollTo(0,0);

You can wire an event handler to the completion of your AJAX call and add that javascript to your event handler.

Upvotes: 4

Related Questions