Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
I am working out of VS2010. Using C# web forms. I have a textbox on a web form and I am trying to get it to display commas when a user enters numbers. In AJax there was a maskedtextbox control for this. Is there a way to display commas in a textbox that is on a web form? If so, can someone show me how? Thanks.
Posted
Comments
SRS(The Coder) 10-Jul-14 9:09am    
Please check with the below plugin, hope will be helpful for you :-
http://digitalbush.com/projects/masked-input-plugin/
deepakaitr12345 10-Jul-14 9:12am    
HI You can use below Js file
autoNumeric-1.7.5.js
Please use this it will be very helpful and remove your extra work
Computer Wiz99 10-Jul-14 9:24am    
Ok. Where will I put this code? And will I have to do this one time for all textboxes or do it for each textbox?

for masking number with comma use this link http://jsfiddle.net/anomepani/G3uKz/1/[^]


and to remove comma when you store to db use code behind string replace method


C#
string value=txtValue.Text.Replace(",","");
 
Share this answer
 
Comments
Computer Wiz99 10-Jul-14 10:22am    
arvind mepani, The code you gave me about the string value, Where should that code be placed? In the Submit button code or Page load?
Computer Wiz99 10-Jul-14 10:42am    
arvind mepani, I looked at the website you gave me and tested it out. It works but if I put in 1800 in the textbox it reads 180,0. Is there a way to have the code to check the numbers and then put int the commas?
Look into localization.

If you set the locale to for example sv-SE for your UI, commas will be expected for decimal values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900