There are a number of ways to do this.
You can use regex patterns, validator controls or just plain key down handling to achieve these results.
Simple key event handling example -
private void txtInputNo_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = (char.IsCharacter(e.KeyChar) || char.IsSpecial(e.KeyChar);
}
The
IsCharacter
and
IsSpecial
methods check if the input character is either of the two.