07 July 2008
How To Scroll To Top Of Page On An AJAX Postback [ASP.NET]
Scrolling to top of the page on an Ajax request in ASP.NET page is quite tricky. The regular inline anchor techniques does not work. We need to handle the endRequest event and scroll the window to 0,0 coordinates(top of the page).
Here is the sample code that can be pasted on your aspx page to scroll an ASP.NET page to top on every Ajax postback operation.
<script type="text/javascript" language="javascript"> Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestEventHandler); function EndRequestEventHandler(sender, args) { scrollTo(0,0) } </script>
Did you enjoy this article? If so, then subscribe to our RSS Feed or free daily newsletter.
Simillar Posts
- How To Perform Client Side Action After Completion Of AJAX Postback Operation[ASP.NET 2.0]
- How To Identify Language of Any Text
- Flip Text, Free Windows 7 Wallpaper, Tech Dreams Mobile Edition, Automatically Switch Wallpapers [Recap]
- 8 Things To Do With Mouse Scroll Wheel In Firefox
- How To Flip Text Like sıɥʇ (This)














































[...] down on the page the AJAX postback wouldn’t return the focus to the top of the next page. This blog post offered a quick solution that solved my problem quite nicely. <script type=”text/javascript” [...]
Great tip!