Breaking News
Loading...
Thursday 11 October 2012

How to apply numeric validation in c#.Net

This code user can not enter any letters and symbol in textbox  user anter only digits.

=> Create project.
=> take textbox from toolbox
=> select textbox and goto propeties window and click on event tab.
=> double click on KeyPress event.
=> write following code

CODE:


 //this code is for when user enter any digit then it alllow to enter but when user enter any letters then it does not alloe to enter letters in textbox..
       private void txtSn_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
            {
                e.Handled=true;
            }
        }

--
/\/ir@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer