0

I’ve a problem with the page jumping after failed asp.net validation. I can restore the scroll state but to do this I need to bind an event after the client side asp.net validators validation fails. I have tried to hook into the events as follows

$('input[type=submit],input[type=image],:button').bind('click', function (e) {
     //.. restore scroll state
)};

OR

$('form').bind('submit', function (e) {
     //.. restore scroll state
});

These fire before the validation fails and the page jumps

I’ve looked at hooking into the javaScript API for the validators but none of these hooks seem to do the trick.

I’ve looked at this SO Answer but I don’t want to fire the validators manually as this is going to cause other issues.

The solution needs to hook into every page of a built out system so the option of removing the asp.net validators and putting in JQuery validation plugin isn’t realistic.

Any ideas how I can wire into the client side event after the validation fails (in a way that can be put into a master page and applied globally).

Many Thanks

2 Answers 2

1

Have you tried using the live() function of the jquery-library instead? I've got rather limited knowledge of the asp-validation. But live lets ju set binding on objects that will be created. It will be deprecated in 1.7 and replaced by on().

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the answer. Unfortunately tried and doesn't work. The bind is working OK - the events are wired to the elements. It's the ordering of the events that is causing the issue
0

After leaving this up for a while - i think the only way this is ever going to happen is to

  1. Remove the asp.net validators and and do the validation in a custom way with JQuery/Javascript OR

  2. Remove the validation summary altogether and just have the failed validation notification next to the individual fields OR

  3. Maybe consider sonething unpleasant like smart edit to at least get IE running

I think in short there was never going to be a quick pluggable way to do this. Substantial rewrites may have been the only solution

That said if anyone knows different please post

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.