System.Web.UI.WebControls Namespace BaseValidator Class
Sets or retrieves the input control to validate.
Inline |
<asp:validator controltovalidate = strID ... > |
Script |
Validator.ControlToValidate [ = strID ] |
strID |
String specifying the ID of the input control to validate. |
The property is read/write with no default value.
Use the ControlToValidate property to specify the input control to validate. This property must be set to the ID of an input control for all validation controls except for the CustomValidator control, which can be left blank.
If you do not specify a valid input control, an exception will be thrown when the page is rendered. The ID must refer to a control within the same container as the validation control. It must be in the same page or user control, or it must be in the same template of a templated control.
The standard controls that can be validated are TextBox, ListBox, DropDownList, RadioButtonList, HtmlInputText, HtmlInputFile, HtmlSelect and HtmlTextArea.
For an input control to be validated, the ValidationPropertyAttribute must be applied to the control.
All validation controls, except the RequiredFieldValidator control, will pass validation if the input control specified by the ControlToValidate property is empty.
The following example demonstrates how to use the ControlToValidate property to specify the input control to validate.
Show me
BaseValidator Members Base Validation Control Properties