有没有办法将RangeValidator用于大数(Int64范围)?
After looking that this there is no clean way to do this with just a rangevalidator. I've listed the alternatives below that use the webforms validators.
HTML:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" ControlToValidate="TextBox1"
runat="server" ErrorMessage="Help" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
HTML Alt:
You could use a combo here. One to verify that its in the 64 bit range and one to validate its just an integer. Seems clunky, but it should work.
<asp:RangeValidator ID="RangeValidator1" ControlToValidate="TextBox1"
runat="server" ErrorMessage="Help" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression="[1-9]\d*"></asp:RegularExpressionValidator>
Code Behind:
protected void Page_Load(object sender, EventArgs e) {
this.RangeValidator1.MaximumValue = Int64.MaxValue.ToString();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.