📅  最后修改于: 2020-12-28 00:38:16             🧑  作者: Mango
该验证器评估输入控件的值以检查该值是否位于指定范围之间。
它使我们可以检查用户输入是否在指定的上下边界之间。此范围可以是数字,字母字符和日期。
注意:如果输入控件为空,则不会执行任何验证。
ControlToValidate属性用于指定要验证的控件。的MinimumValue和MaximumValue属性用于对控制集合的最小和最大边界。
Property | Description |
---|---|
AccessKey | It is used to set keyboard shortcut for the control. |
TabIndex | The tab order of the control. |
BackColor | It is used to set background color of the control. |
BorderColor | It is used to set border color of the control. |
BorderWidth | It is used to set width of border of the control. |
Font | It is used to set font for the control text. |
ForeColor | It is used to set color of the control text. |
Text | It is used to set text to be shown for the control. |
ToolTip | It displays the text when mouse is over the control. |
Visible | To set visibility of control on the form. |
Height | It is used to set height of the control. |
Width | It is used to set width of the control. |
ControlToValidate | It takes ID of control to validate. |
ErrorMessage | It is used to display error message when validation failed. |
Type | It is used to set datatype of the control value. |
MaximumValue | It is used to set upper boundary of the range. |
MinimumValue | It is used to set lower boundary of the range. |
在以下示例中,我们使用RangeValidator验证指定范围内的用户输入。
// RangeValidator.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RangeValidator.aspx.cs"
Inherits="asp.netexample.RangeValidator" %>
输出:
当输入不在范围内时,它将引发错误消息。