asp.net.ph

BaseValidator.ControlToValidate Property

System.Web.UI.WebControls Namespace   BaseValidator Class


Sets or retrieves the input control to validate.

Syntax


Inline <asp:validator controltovalidate = strID ... >
Script Validator.ControlToValidate [ = strID ]

Property Value


strID String specifying the ID of the input control to validate.

The property is read/write with no default value.

Remarks

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.

Example

The following example demonstrates how to use the ControlToValidate property to specify the input control to validate.

 Show me 

See Also

BaseValidator Members   Base Validation Control Properties Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph