Table of ContentsASP .NET: Validating User Input with C#
Required 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.