ASP.NET Mobile CompareValidator Control[转]
Definition and Usage
定义和用法
The CompareValidator control is used to compare the value of one input control to the value of another input control or to a fixed value.
CompareValidator控件的作用是:拿其中一个输入控件的值和另外一个输入控件的值或一个固定值相比较。
Note: The validation will not fail if the input control is empty. Use the RequiredFieldValidator control to make the field required.
注意:如果输入控件是空值,那么验证将不会失败。使用RequiredFieldValidator 控件可以使字段变为必要字段。
Properties
属性
| Property 属性 |
Value 值 |
Description 描述 |
|---|---|---|
| Alignment | left center right |
Optional. How to align the control 可选参数。指定控件的排列方式 |
| BackColor | rgb(x,x,x) #xxxxxx colorname |
Optional. A background color for the control 可选参数。指定控件的背景颜色 |
| ControlToCompare | id_of_control | Optional. The name of the control to compare with 可选参数。指定参与比较的控件名称 |
| ControlToValidate | id_of_target_control | Optional. The id of the control to validate 可选参数。指定参与验证的控件id |
| Display | None Static Dynamic |
Optional. The display behavior for the validation control. Legal values are: 可选参数。指定确认控件的显示方式。合法值如下:
Dynamic is default |
| ErrorMessage | errortext_for_summary | Optional. The text to display in the ValidationSummary control when validation fails 可选参数。当验证失败时,将在ValidationSummary 控件中显示文本信息 |
| ForeColor | rgb(x,x,x) #xxxxxx colorname |
Optional. A foreground color for the control 可选参数。指定控件的前景色 |
| Font-Bold | false true |
Optional. Specifies whether or not the text in the control should be bold 可选参数。指定控件中的文本字体是否以粗体显示 |
| Font-Italic | false true |
Optional. Specifies whether or not the text in the control should be italic 可选参数。指定控件中的文本字体是否以斜体显示 |
| Font-Name | fontname | Optional. Specifies the font name of the text in the control 可选参数。指定空间中的文本字体名称 |
| Font-Size | normal small large |
Optional. Specifies the font size of the text in the control 可选参数。指定空间中的文本字体尺寸 |
| id | unique_name | Optional. A unique id for the control 可选参数。为空间指定一个独立的id |
| Operator | DataTypeCheck Equal GreaterThan GreaterThanEqual LessThan LessThanEqual NotEqual |
Optional. The type of comparison to perform 可选参数。指定参与比较的类型 |
| runat | "server" | Required. Specifies that the control is a server control 必要参数。指定该控件为服务器控件 |
| StyleReference | name_of_style_element | Optional. Specifies a reference to a style to be applied to the control 可选参数。指定一个应用于控件的样式参数 |
| Text | errortext | Optional. The message to display when validation fails 可选参数。当验证失败时,指定显示的信息 |
| Type | Currency Date Double Integer String |
Optional. Specifies the data type of the values to compare 可选参数。指定参与比较的值的日期类型 |
| ValueToCompare | value | Optional. A specified value to compare with 可选参数。指定参与比较的值 |
| Wrapping | wrap nowrap |
Optional. Specifies whether or not the text in the control should wrap 可选参数。指定控件中的文本是否允许被嵌套 |
Example 1
案例1
The following example contains two forms in an .aspx file. The first form has a label with the text "Age?", an input box to input the age, and a submit button. The second page is activated by the submit button on the first page, and displays a response. If the input value validates as an error, an error message is displayed:
下面的案例包含了 .aspx 文件中的两张表单。第一张表单包含一个名为“Age?” 的标签,以及一个输入框和提交按钮。第二张页面将被第一张页面中的啼叫按钮激活。如果输入值确认出现错误,那么将显示一段错误信息:
<%@ Page <script runat="server"> <Mobile:Form id="f1" runat="server"> <Mobile:Form id="f2" runat="server"> |
浙公网安备 33010602011771号