Validation controls

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi all,

Have a number of required field validators on my web form. The EnableClientScript is set to False. I also have validation summary control on my page.

When I hit the save button, a method called ExecuteValidation is called. This method firstly calls the individual validators.
Code:
 me.requiredFieldValidator1.validate
 me.requiredFieldValidator2.validate
 me.requiredFieldValidator3.validate

The method then proceeds to check if the validator is correct or not.
Code:
 if me.requiredFieldValidator1.isvalid = false then
  ExecuteValidation = false
 end if
 if me.requiredFieldValidator2.isvalid = false then
  ExecuteValidation = false
 end if
 if me.requiredFieldValidator3.isvalid = false then
  ExecuteValidation = false
 end if

The problem that I am having is that I want the validation statements for requiredFieldValidator 1, 2, and 3 to appear in the order 1, 2, 3. However I practice the order is constantly changing.

Any suggestions on how to control the order?

Mike55.
 
IIRC you shouldn't have to manually invoke the validators on a post back - the framework should invoke them automatically.
If you want to check if things worked or not you could then check to see if a validator is valid or not or alternatively just query Page.IsValid to detect if any errors are present and act accordingly.
 
Back
Top