如何在文本框中显示逗号但不保存到数据库? [英] How to display commas in textbox but not save to database?

查看:105
本文介绍了如何在文本框中显示逗号但不保存到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2010工作。使用C#Web表单。我在网络表单上有一个文本框,我试图在用户输入数字时显示逗号。在AJax中有一个maskedtextbox控件。有没有办法在Web表单上的文本框中显示逗号?如果是这样,有人可以告诉我如何?谢谢。

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.

推荐答案

用逗号屏蔽数字使用此链接 http: //jsfiddle.net/anomepani/G3uKz/1/ [ ^ ]





并在存储到db时删除逗号使用代码后面的字符串替换方法





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


string value=txtValue.Text.Replace(",","");


查看本地化。



如果您将区域设置设置为例如用户界面的sv-SE,则预期小数值将为逗号。
Look into localization.

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


这篇关于如何在文本框中显示逗号但不保存到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆