验证TextBox只输入数字

<asp:textbox class="Text"
        onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;"
 id="txtY_Revenue" style="TEXT-ALIGN: right" runat="server" Width="90%" MaxLength="12">
    </asp:textbox>

或者:

 if (Tbx_Edition.Text != "")
        {
            bool a1=true;
            foreach(char c in Tbx_Edition.Text)
            {
                if(char.IsNumber(c))
                {
                    continue;
                }
                else if(c=='.')
                {
                    continue;
                }
                else
                {
                    a1 = false;
                    break;
                }
            }

}

原文地址:https://www.cnblogs.com/hyd309/p/1282689.html