Version

Validating WebDropDown using RequiredFieldValidator Control

Before You Begin

WebDropDown™ can easily be validated using the RequiredFieldValidator control to ensure that the end-user selects at least one item from the drop-down list.

In this walkthrough, you will validate a WebDropDown control with the click of a button.

What You Will Accomplish

You will learn how to validate WebDropDown using the RequiredFieldValidator.

Follow these Steps

  1. From the Visual Studio™ Toolbox, drag and drop a ScriptManager component, a WebDropDown control, a standard Button control and a RequiredFieldValidator validation control.

  2. Add items to the WebDropDown as shown in the Adding Items to WebDropDown using the Designer topic.

  3. Set the following properties of the RequiredFieldValidator control in the property window:

ControlToValidate ErrorMessage

WebDropDown1

*Please select an item from the drop-down.

  1. Save and run your application. Delete the item in the value display of the WebDropDown and click the button. You will observe an error message displayed similar to the following image:

WebDropDown Validating WebDropDown using%20 the RequiredFieldValidator Control 01.png