Sam*_*jus 19 c# string.format asp.net-mvc-3
我想@String.Format("{0:0.00}",Model.CurrentBalance)进入这个@Html.TextBoxFor(model => model.CurrentBalance, new { @class = "required numeric", id = "CurrentBalance" })
我只是希望货币在我的文本框中显示为.00但是没有运气.关于我如何做这个的任何想法?
Sam*_*Axe 29
string.format("{0:c}", Model.CurrentBalance) 应该给你货币格式.
要么
@Html.TextBoxFor(model => model.CurrentBalance, new { @class = "required numeric", id = "CurrentBalance", Value=String.Format("{0:C}",Model.CurrentBalance) })
Gai*_*oad 15
@Html.TextBoxFor(model => model.CurrentBalance, "{0:c}", new { @class = "required numeric", id = "CurrentBalance" })
Run Code Online (Sandbox Code Playgroud)
这使您可以设置格式并添加任何额外的HTML属性.