How can I prevent a page to jump to top position after failed validation?

Posted by Slauma on Stack Overflow See other posts from Stack Overflow or by Slauma
Published on 2010-04-10T12:50:10Z Indexed on 2010/04/10 12:53 UTC
Read the original article Hit count: 269

I have a simple aspx page with a few TextBoxes and a submit button. Some fields are required and below the button is a ValidationSummary. The complete form is larger than screen height so one has to scroll down to reach the submit button. If I don't fill all required fields and click on submit validation fails as expected and the validation summary displays some info messages below the button. Validation happens on the client and no postback occurs.

So this all works as wished. But disturbing is that the page moves ("jumps") to top position when I click on the submit button. To see the validation summary one has to move down the page again.

I've tried to set the ShowSummary property to false (which doesn't make much sense): The validation still works (no postback) but in this case the page does not move to top position. So the problem seems to depend on rendering the validation texts.

Is there a way to prevent this page jump?

Thank you in advance!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about validation