private void Quantity_txt_KeyPress(object sender, KeyPressEventArgs e) { char ch = e.KeyChar; if (!Char.IsDigit(ch) && ch != 8 && ch != 46) { e.Handled = true; } }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = ((new Char[] {'0','1','2','3','4','5','6','7','8','9'}).ToList<Char>()).Contains(e.KeyChar)?false:true; //you can either change it to e.Handled = char.IsDigit(e.KeyChar) ? false : true; }
e.Handled = !char.IsDigit(e.KeyChar);
NumericUpDown
<ajaxtoolkit:toolkitscriptmanager id="ajsm" runat="server" ></ajaxtoolkit:toolkitscriptmanager> <asp:textbox id="TextBox1" runat="server" ></asp:textbox> <ajaxtoolkit:filteredtextboxextender id="fteIn" runat="server" targetcontrolid="TextBox1" filtertype="Numbers" > </ajaxtoolkit:filteredtextboxextender>
&& ch != 46
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)