In the above example we have tied two validation controls to the Hire Date Text Box.
The Range Validator does not validate the contents of an input control if the control is empty.
As we mentioned earlier, validation controls execute when the user clicks a Button control, including HTML button controls and server button controls such as the Link Button and Image Button.
All of the validation controls must have the Control To Validate property set before rendering the page or the control throws an exception.
The code in our ASPX file should look like the following.
There are various validation controls availabe, and we will cover them in the rest of the article.
All of the validation controls derive from the Base Validator class, giving them common methods and properties.
We can double click on both of the Button controls on the form to add event handlers for the click events. If you want to disable just client side validation for a specific validation control, you can set the control’s Enable Client Script property to false. NET will always execute validation checks on the server when a button click event arrives requiring validation.
The complete listing for Web Form1cs is shown below. You can disable any of the validation controls by setting the Enabled property to false.