Asp – What are the valid server controls that can be used in the CustomValidator.ControlToValidate property

asp.net

I'm wondering if anyone knows what are the valid Asp.Net server controls that can be used with the CustomValidator.ControlToValidate property.

For example I know that you can validate a TextBox.

However, when using some other types of controls I receive the following error:

System.Web.HttpException: Control 'xxx' referenced by the ControlToValidate property of 'yyy' cannot be validated.

This happens when using RadioButton controls for example.

Is there an established list of valid Server controls that can be used in the ControlToValidate property?

Best Answer

From this link:

  • RadiobuttonList
  • DropDownList
  • ListBox
  • TextBox
  • HtmlInputFile
  • HtmlSelect
  • HtmlTextArea
  • HtmlInputText

Note that you can validate any control you want with a CustomValidator, as it doesn't requite a target control.