How do I scroll to the top of an ASP.NET page after postback?

Hi Experts,

I use this on top of my ASP.NET page to maintain the scroll position after postback.

<%@ Page Language="VB" MaintainScrollPositionOnPostback="true" %>

This comes in handy because I have a long form, with Listboxes that do Autopostabacks.  When I click the Submit button though, I want to page to scroll back to the top of the page, because any error messages are displayed on the top of the page.

How can I accomplish this?
Who is Participating?
TechTiger007Connect With a Mentor Commented:
You can either use javascript
ClientScript.RegisterStartupScript(gettype(),"scroll(0,0)", true);

or disable MaintainScrollPositionOnPostback during submit click
Page.MaintainScrollPositionOnPostback = false
crickpaoloAuthor Commented:
perfect! thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.