Introduction to the RequiredFieldValidator Control 

.NET Framework 3.0

Use the RequiredFieldValidator control to validate that the user entered a data value into a SelectionList or TextBox control. With a SelectionList control, the user must select an item in the list. With a TextBox control, the user must enter a value.

ASP.NET Required Field Validator

Set the RequiredFieldValidator control's ControlToValidate property to the ID of the SelectionList or TextBox control to validate. If the data value is not present, the RequiredFieldValidator control displays the value of its ErrorMessage property.

When you add a RequiredFieldValidator control to a container control or template:

  • The ErrorMessage property is set to "RequiredFieldValidator".

  • The StyleReference property is set to error, which is the name of a predefined style in the default StyleSheet object.

For detailed information about properties of this control, see the Properties section of the RequiredFieldValidator topic.

See Also

Community Additions