使用Int64的Asp.Net RangeValidator [英] using Asp.Net RangeValidator for Int64

查看:52
本文介绍了使用Int64的Asp.Net RangeValidator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将RangeValidator用于大数(Int64范围)?

Is there a way to use RangeValidator for large numbers (Int64 range)?

推荐答案

在看完这之后,没有一种简单的方法可以通过rangevalidator来做到这一点.我在下面列出了使用网络表单验证器的替代方法.

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:

您可以在此处使用连击.一个用于验证其在64位范围内,另一个用于验证其仅为整数.似乎笨拙,但应该可以.

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>

后面的代码:

protected void Page_Load(object sender, EventArgs e) {
      this.RangeValidator1.MaximumValue = Int64.MaxValue.ToString();
    }

这篇关于使用Int64的Asp.Net RangeValidator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆