Using the below code you can only enter numbers to the textbox. Here you have to paste this code in the keypress event of the textbox which is there in the property of that textbox.
e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 13 ? false : true;
e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 13 ? false : true;
if (char.IsNumber(e.KeyChar) || (e.KeyChar >= 48 && e.KeyChar <= 57) || (e.KeyChar == 8))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
No comments:
Post a Comment