Bas*_*ger 2 asp.net-mvc textbox
如何为文本框指定MaxLength,如MaxLenth ="18"
如何在模型中将TextBox格式字符串设置为FormatString ="$ ###,###,###,## 0.00",这样即使我输入100,它也应自动变为$ 100.00
如何为文本框指定MaxLength,如MaxLenth ="18"
您可以将其他html属性传递给该TextBoxFor方法:
<%= Html.TextBoxFor(x => x.SomeValue, new { maxlength = "18" })
Run Code Online (Sandbox Code Playgroud)
如何在模型中将TextBox格式字符串设置为FormatString ="$ ###,###,###,## 0.00",这样即使我输入100,它也应自动变为$ 100.00
您可以使用以下[DisplayFormat]属性:
[DisplayFormat(DataFormatString = "{0:$###,###,###,##0.00}", ApplyFormatInEditMode = true)]
public decimal? Value { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后:
<%= Html.EditorFor(x => x.Value) %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3041 次 |
| 最近记录: |