Technical Training
ASP.NET TrainingTable of Contents
ASP .NET: Validating User Input with C#
Required Field Validator
Regular Expression Validator
Range Validator
Compare Validator
Custom Validator
Validation Summary ControlRequired field validator is used for required fields. Fields that cannot be left empty is validated using the required field validator. A good example will be a TextBox which is used for taking the username as the input. Since the user must enter the username in the TextBox in order to access the website. The required field validator can be used with the TextBox control to validate the input. If user does not enter any data in the TextBox than an error message is displayed and further processing of the request will be stopped. In order to set the Required validator on the TextBox control just drag and drop the validator on the webform and set its ControltoValidate property to the TextBox id you want to validate.
The Page.IsValid property is true if the page does not have any error messages to display. The Required field validator performs the validation first on the client side and than on the server side.
ASP.NET Training
H I D E