首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >TextBoxFor上货币的String.Format

TextBoxFor上货币的String.Format
EN

Stack Overflow用户
提问于 2011-08-06 07:04:53
回答 2查看 56.3K关注 0票数 20

我正在尝试让@String.Format("{0:0.00}",Model.CurrentBalance)进入这个@Html.TextBoxFor(model => model.CurrentBalance, new { @class = "required numeric", id = "CurrentBalance" })

我只想让货币在我的文本框中显示为.00,但我没有运气。你知道我是怎么做的吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-06 07:14:41

string.format("{0:c}", Model.CurrentBalance)应该会给你提供货币格式。

@Html.TextBoxFor(model => model.CurrentBalance, new { @class = "required numeric", id = "CurrentBalance", Value=String.Format("{0:C}",Model.CurrentBalance) })

票数 31
EN

Stack Overflow用户

发布于 2016-04-27 21:35:33

代码语言:javascript
复制
@Html.TextBoxFor(model => model.CurrentBalance, "{0:c}", new { @class = "required numeric", id = "CurrentBalance" })

这使您可以设置格式并添加任何额外的HTML属性。

票数 19
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6963497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档