Execution order of Validation Controls

B

Bijoy Naick

I have 3 labels called eventDate, eventStartTime and eventEndTime.

I have 3 validators as well. One checks to make sure that a date is
specified (RequiredFieldValidator), the other makes sure that the date
is valid (CompareFieldValidator) and the third (a custom validator)
makes sure that the eventStartTime is before the eventEndTIme. The
custom validator takes the eventDate and start/end times, creates 2
variables of type DateTime and does a compare.

Is there a way for me to define the order in which the validators will
run? I'd like the Required to run first, follwoed by the Compare and
then the Custom.

Thx.

Bijoy


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
M

Martin Marinov

You can do it manually
e.g.
on submit, instead of call Page.Validate() method you can use

RequiredFieldValidator.Validate();
if ( RequiredFieldValidator.IsValid )
{
CompareFieldValidator.Validate();
if ( CompareFieldValidator.IsValid )
{
CustomValidator.Validate();
if ( CustomValidator.IsValid )
{
}
}
}

for this you have to perform the validation on the server and set the
EnableClientScript = False

Regards
Martin
 

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,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top