By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Client-side validation is resetting scroll position

P: n/a
Hello all,

I have a "comments" page that contains three sections; the article to
be commented on is on top, followed by previous comments, and on the
bottom a place to add new comments. It's a pretty common scenario.

I have two links from the main article page; one to view the comments
and one to add a new comment. I'm simply using <span id="top"and
<span id="bottom">, and #top or #bottom in the query string to
distinguish between the two. This works beautifully.

However, the issue comes with the client-side validation. I'm using
ASP.NET 2.0's built-in validation controls. For some reason, the
javascript that validates the controls when I hit my submit button is
automatically scrolling the page back to the top, which is unacceptable
because the user has to scroll back down to the bottom every time there
is an error with their entry. The page is not posting back at this
point; I've read numerous articles on how to maintain scroll position
across postbacks, but this is client-side validation.

On a further note, my site works properly without javascript enabled as
well. ASP.NET's validation controls handle this properly and simply
post back to the server to do all validation. In this scenario, I'd
like to know of a way to scroll back down to the bottom of the page if
errors occurred in the validation, or stay at the top if they did not.

Any ideas/suggestions/solutions would be greatly appreciated, and I'm
willing send $5 via PayPal to whoever can solve my problem. Not that
$5 is a lot of money :).

Thanks for your help in advance!


Nov 24 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.