Start Validating controls in asp net

Validating controls in asp net

Also, the Validator Get Value function of the asp: Validators was overriden to look our expando property called “Rad Input Validation Value”.

Normally, these validation controls will fire when the data is entered in the input controls are not valid and prevent the user to post the data to server.

Net has packed with a handful of inbuilt validation control that assists us in client side input validations.

If you have two textboxes that each have a validation control applied against it, and two buttons on the form, both validation controls will always check for validation together – there is no way to cause one of the validation controls to fire when one button is clicked, and the other to fire when the other button is clicked.

Using the Validation Group property is simple – just add a “Validation Group” property to the validation controls that you want to group together, and then add the same Validation Group name to the postback control (for example: a button) that you want to cause the validation to occur.

If the validators are set to use client-side validation (their Enable Client Script property is True), the Rad Input controls automatically trigger the validator that checks their value when the user finishes editing.

That is, when the user has changed the value in the control and it then loses focus, the validator checks the new value of the input control.

Why don’t we just create a custom class that injected a styled error message next to our offending control?

We could satisfy the first goal because we know where the message will go, and the user will be able to easily understand what is incorrect or missing.

Also we would have complete control over the validation in our server side code.

The validation controls are used to validate user input.

For example a Required Field Validator can be used to make sure the user does not skip mandatory fields.