ASP.NET CustomValidator control
Definition and Usage
CustomValidator control allows you to process the input values validated methods of writing.
Attributes
属性 | 描述 |
---|---|
BackColor | CustomValidator 控件的背景颜色。 |
ClientValidationFunction | 规定要被执行的客户端脚本函数的名称。
注释:脚本必须用浏览器支持的语言编写,比如 VBScript 或 JScript
使用 VBScript 时,函数必须位于表单内: Sub FunctionName (source, arguments) 使用 JScript 时,函数必须位于表单内: Function FunctionName (source, arguments) |
ControlToValidate | 要验证的控件的 id。 |
Display | 验证控件的显示行为。合法值有:
|
EnableClientScript | 布尔值,规定是否启用客户端验证。 |
Enabled | 布尔值,规定是否启用验证控件。 |
ErrorMessage | 当验证失败时,在 ValidationSummary 控件中显示的文本。 注释:如果未设置 Text 属性,文本也会显示在验证控件中。 |
ForeColor | 控件的前景色。 |
id | 控件的唯一 id。 |
IsValid | 布尔值,指示由 ControlToValidate 指定的控件是否通过验证。 |
OnServerValidate | 规定被执行的服务器端验证脚本函数的名称。 |
runat | 规定该控件是服务器控件。必须设置为 "server"。 |
Text | 当验证失败时显示的消息。 |
Examples
CustomValidator
In this example, we declare in an .aspx file two Label controls, a TextBox control, a Button control, and a CustomValidator control. user () function can detect the length of the input value. If the length is less than 8 or greater than 16, the text "A username must be between 8 and 16 characters!" In CustomValidator control.
Validation Server Controls