views:

521

answers:

1

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

I would like the return (same) page to scroll smoothly to the top of the page, rather than a sudden jump. It's a better user experience in my opinion.

I am looking for c# + Javascript code to do this effect or at least the JS smooth scrolling effect.

+2  A: 

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

Or just write the animation yourself:

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

BRH
Thanks. It didn't work for me but this variation worked. $('html, body').animate({ scrollTop: 0 }, 'slow');
Abdu