如题
在线等答案

解决方案 »

  1.   

    http://ajax.asp.net/ajaxtoolkit/FilteredTextBox/FilteredTextBox.aspx
      

  2.   

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RegularExpressionValidator
                ID="RegularExpressionValidator1" runat="server" ErrorMessage="*" ControlToValidate="TextBox1" ValidationExpression="\d*"></asp:RegularExpressionValidator>
      

  3.   

    WINFORM 
    还是
    ASP.NET
      

  4.   

    WINFORM 
    用MaskTextBox,设置Mask好了
      

  5.   

    写个事件。System.Windows.Forms.KeyPressEventArgs 触发
      

  6.   

    在TextChange事件里引用该方法。
            public static void ValidNum(System.Windows.Forms.TextBox textbox, int minValue, int maxValue)
    {
    if (textbox.Text=="")
    return; if (IsNumeric(textbox.Text)==false||Convert.ToDouble(textbox.Text)<minValue||Convert.ToDouble(textbox.Text)>maxValue)
    {
    textbox.Text=textbox.Text.Substring(0,textbox.Text.Length-1);
    if (textbox.Text.Length>=1)
    {
    textbox.SelectionStart=textbox.Text.Length;
    }
    }


    }
      

  7.   

    上策:改用NumericUpDown控件
    中策:声明一个int(或根据需要,double)属性,将TextBox的Text绑定上去
    下策:自写代码实现
      

  8.   

    如果是Winform
    就用keypress事件就可以了
    private void txtJan_KeyPress(object sender,System.Windows.Forms.KeyPressEventArgs e)
    {
        if( !( e.KeyChar <= '9'   &&   e.KeyChar >= '0' ))
       {
    e.Handled=true;
       }
    }