ASP.NET RangeValidator control

Definition and usage

The RangeValidator control is used to check whether the user's input value is between two values. It can compare different types of values, such as numbers, dates, and characters.

Note:If the input control is empty, the validation will not fail. Please use the RequiredFieldValidator control to make the field required.

Note:If the input value cannot be converted to the specified data type, the validation will not fail. Please use the CompareValidator control, set its Operator property to ValidationCompareOperator.DataTypeCheck, so you can check the data type of the input value.

Property

Property Description
BackColor Background color of the RangeValidator control
ControlToValidate The id of the control to be validated
Display

Display behavior of the validation control.

Valid values include:

  • None - The validation message is never displayed inline.
  • Static - The space for displaying the validation message is allocated in the page layout.
  • Dynamic - If validation fails, the space for displaying the validation message is dynamically added to the page.
EnableClientScript Boolean value, specifies whether to enable client-side validation.
Enabled Boolean value, specifies whether to enable the validation control.
ErrorMessage

当验证失败时,在 ValidationSummary 控件中显示的文本。

注释:如果未设置 Text 属性,文本也会显示在该验证控件中。

ForeColor 该控件的前景色。
id 控件的唯一 id。
IsValid 布尔值,指示关联的输入控件是否通过验证。
MaximumValue အသုံးပြုခြင်း၏ အမြင့်ဆုံး အရာ
MinimumValue အသုံးပြုခြင်း၏ အနည်းဆုံး အရာ
runat အပြင်ဆင်ခြင် အပြုအမူ သတ်မှတ်ပါ။ အပြင်ဆင်ခြင် အပြုအမူ သတ်မှတ်ပါသည်။
Type

စစ်ဆေးသင့်သောအရာ၏ အချက်အရာအမျိုးအစားကို သတ်မှတ်ပါ။ အမျိုးအစားများ:

  • Currency
  • Date
  • Double
  • Integer
  • String
အချက်အလက် စစ်ဆေးမရှိခဲ့လျှင် ပြသောအချက်အလက်

အများပြားသောအကျိုးသက်

RangeValidator
ဒီအချက်အလက်တွင် သင်တော်မူ တ.aspx ဖိုင်တွင် TextBox အပြင်ဆင်ခြင် တစ်ခု၊ Button အပြင်ဆင်ခြင် တစ်ခု နှင့် RangeValidator အပြင်ဆင်ခြင် တစ်ခု ဖြစ်ပေါ်စေသည်။ စစ်ဆေးမရှိခဲ့လျှင် တွင် RangeValidator အပြင်ဆင်ခြင် တွင် "The date must be between 1/1/2002 and 31/5/2002!" ကို ပြသပါသည်။
RangeValidator 2
ဒီအချက်အလက်တွင် သင်တော်မူ တ.aspx ဖိုင်တွင် TextBox အပြင်ဆင်ခြင် တစ်ခု၊ Button အပြင်ဆင်ခြင် တစ်ခု၊ Label အပြင်ဆင်ခြင် တစ်ခု နှင့် RangeValidator အပြင်ဆင်ခြင် တစ်ခု ဖြစ်ပေါ်စေသည်။ submit() အက္ခရာမှာ စာတမ်းကို အရေးယူခြင်းကို စစ်ဆေးနိုင်ပါသည်။ အရေးယူခြင်းအရာဖြစ်လျှင် တွင် Label အပြင်ဆင်ခြင် တွင် "The page is valid!" ကို ပြန်လည်ပြောဆိုပါသည်။ အရေးယူခြင်းမရှိလျှင် တွင် Label အပြင်ဆင်ခြင် တွင် "The page is not valid!" ကို ပြန်လည်ပြောဆိုပါသည်။ စစ်ဆေးမရှိခဲ့လျှင် တွင် RangeValidator အပြင်ဆင်ခြင် တွင် "The value must be from 1 to 100!" ကို ပြသပါသည်။