You can do it on text box key press event or you can use ajax control (filter text).
Below i saw you how to do that on key press event :
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar)
&& !char.IsDigit(e.KeyChar)
&& e.KeyChar != '.')
{
e.Handled = true;
}
if (e.KeyChar == '.'
&& (sender as TextBox).Text.IndexOf('.') > -1)
{
e.Handled = true;
}
}
For more detail refer this link :
http://stackoverflow.com/questions/463299/how-do-i-make-a-textbox-that-only-accepts-numbers[
^]
Accept as answer or vote if help.