Validating dropdownlist asp net

Using Image as a Validation Message in Validation Control We can also set some images as a validation messages when we use validator control.

For example, we can show mandatory image as a validation message if a field is mandatory with Required Field validator control.

Net Re using Inbuilt Validation Control Scripts from Java Script Sometimes, we would like to reuse our validator control and call it from Javascript. explicitly calling a inbuilt validator control script.

A practical example will be calling a validator that belongs to a different validation group from a button click that does not belong to that validation group. Is Valid property will hold the input form validation status in Is Valid property when you check in a event that does not belongs to that validation group but still it requires to pass the validations on that group.

This article will help us to use the validation control to the maximum extent to serve our project needs.

Validator control will fire on blur By default, when we use validator control it will fire the validations on blur of the control.

Validations on user input can be done in 2 ways, Server Side Validation We cannot solely rely upon client side validation because there are chances that the javascript may be disabled on client machine.

Thus, we have understood how we can use the existing validator control to the full extent so that our business requirement is fulfilled.

NET 2.0 I've a simple test webform with a Grid View.

To make the Required Field validator to work for Drop Down List we need to set the Initial Value property to the default value of the Drop Down List for doing mandatory check with Required Field validator. To restrict this behavior for a control, say a Button, we need to set the Causes Validation property to false. Net 1.x lacks in providing a feature to make the validation controls applied to a group of controls.

Setting this property to false means we can’t use any validation control to validate the input for that button till ASP. To answer this, 2.0 introduced a new feature with validation control called Validation Group where we can validate group of controls separately.

Leave a Reply