开发者

using Asp.Net RangeValidator for Int64

开发者 https://www.devze.com 2023-02-21 18:01 出处:网络
Is there a way to use RangeValidator for large numbers (Int开发者_如何学Python64 range)?After looking that this there is no clean way to do this with just a rangevalidator.I\'ve listed the alternative

Is there a way to use RangeValidator for large numbers (Int开发者_如何学Python64 range)?


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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消