Execution order of Validation Controls

  • Thread starter Thread starter Bijoy Naick
  • Start date Start date
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!
 
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
 
Back
Top