5
Answers

ASP Validation

Jon H

Jon H

14y
1.9k
1
Hi Guys,

We have an asp wizard set up that has some text boxes etc in it. We use RequiredFieldValidator for some of these and some other validators also.

The default behaviour seems to be that you can tab from field to field initially with no validation but after you press next it turns on the in-line validation that seems to happen on-the-fly.

Does anyone know if there is anyway to control this? i.e. it is on-the-fly all the time or only updates when next is pressed? (ideally the former)

Cheers.
Answers (5)
0
Jaish Mathews

Jaish Mathews

NA 7.3k 1.2m 14y

John,
Vlidator will be fired on any click only. Just pressing tab won't fire validator controls. 1st check that this validation is from validatorcontrol itself.
Now You can make all validator control to "Enabled=False". Then none of them will fire. Later you can make them fire in click like below.
protected void Button1_Click(object sender, EventArgs e)
        {
            //Enabling ValidatorControl
            RequiredFieldValidator1.Enabled = true;
            //Firing all validator controls in page manually
            Page.Validate();
            //Check that specific ValidatorControl passed the validation or not. If passed, then only server activities
            if (RequiredFieldValidator1.IsValid)
            {
                Response.Redirect("http://www.google.cpm");
            }
        }
 
NB:The above example only for a single ValidatorControl. You need to do this for each and evry ValidatorControls you have. You can use Page.Validators to loop through each and every ValidationControls of a page.
0
Jon H

Jon H

NA 18 0 14y
Sorry, I don't understand how this would help in my case? It seems the validators have a specific behaviour that can not be overridden?

I either wants constant on the fly validation i.e. validators flag as and when i leave cells.

OR

I want validation to only update when you press some button (next in my case as I am using a wizard)
0
Jon H

Jon H

NA 18 0 14y
So there is no way to override the next button press for validation and have the client-side validation happen from the beginning? I am using the asp wizard if that helps.
0
Crish

Crish

NA 3.7k 76.4k 14y

hi

set causevalidation false for this button.

thanks
0
ajay raju

ajay raju

NA 384 0 14y

hi jon,
Basically Validation controls of asp.net is validated on client - side. but first time it validate only you click submit button and next time also it  validates client side not a server side validation.
                   if you want to show validtions when you click button you must write manual coding, (or) try to use validation summary control,
may be it helpful to you.
Thanks.