.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
satyapriyanayak
Subhransu Sekhar Jena
abhays
SP
DotnetUser

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Not to allow special characters in cell no textbox

Posted By:Syed Shakeer Hussain       Posted Date: February 16, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  
 


The below code is useful when you don't want to enter any special characters in a cellNo textbox..

1.First select your TextBox and click on Events.

2.Next select and double click on Keypress event and write below code ..
 
Private void textbox1_KeyPress(object sender,EventArgs e) 
{
if(char.IsNumber(e.KeyChar)!=true)
{
e.Handle=true;
}
}
3.if you want to work a BackSpace Key write above code

if(e.keychar=='\u0008')
{
e.Handle=false;

}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend