Smooth page scroll after asp.net ajax postback

I have an error message area at the top of a long page. After switching ajax back to asp.net (using the update panel) sometimes I need to display an error message and it will be displayed outisde in the viewport, and the user may not notice it.

I would like the return page (of the same) to scroll smoothly at the top of the page, rather than a sudden jump. In my opinion, this is the best user interface.

I am looking for C # + Javascript code to make this effect, or at least the smooth JS scroll effect.

+4
source share
1 answer

You can just use jQuery and scrollTo: http://demos.flesler.com/jquery/scrollTo/

Or just write the animation yourself:

$ ('body'). Animate ({scrollTop: 0}, 1000);

+4
source

All Articles