Client-side validation is resetting scroll position

J

jasondavidcarr

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!

Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top