Briefly explain how the server control validation controls work.

Showing Answers 1 - 2 of 2 Answers

Takrim Khan

  • Jul 21st, 2005
 

A validation control works by evaluating the value of an input server control on the page to see whether it meets certain criteria. The input control to evaluate is specified through the validation control?s ControlToValidate attribute. You can programmatically cause a validation control to perform its evaluation by calling its Validate method, which sets the validation control?s IsValid property to true if validation succeeds and false if it fails. You can cause all of the validation controls on a page to validate their input controls by calling the Page.Validate method. 
 
The Page.IsValid property is set to true if validation succeeds for all validation controls within the page; otherwise, it's false. The Page.Validate method is automatically invoked when a button control whose CausesValidation property is set to true is clicked. CausesValidation is set to false by default for a reset or clear button. The button click event is suppressed if IsValid is false for any validation control on the page 
 
 

  Was this answer useful?  Yes

samiksc

  • Jan 16th, 2006
 

There are following types of validation controls provided by ASP.Net:

  1. RequiredFieldValidator
  2. CompareValidator
  3. RangeValidator
  4. RegularExpressionValidator
  5. CustomValidator

These controls are server side controls. However in up-level browsers that is IE 4.0 and above these can be enabled on client side also.

All these controls have a property called ControlToValidate.

RequiredFieldValidator ensures data entry into the ControlToValidate.

CompareValidator uses ControlToValidate, ControlToCompare and operator properties to compare a control's value with another control's value. It also has a property 'ValueToCompare' for comparing ControlToValidate against a constant value.

RangeValidator uses ControlToValidate, MaximumValue and MinimumValue to compare a controls value against a range.

RegularExpressionValidator uses ControlToValidate and ValidationExpression properties.

CustomValidator performs its task by using ClientValidationFunction and OnServerValidate delegate.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions