开发者

FormatString for a TextBoxFor() in Asp.NET MVC

  • How to specify MaxLength for a textbox , Like MaxLenth="18"

  • How to Set the TextBox Format String as FormatString="$###,###,###,##0.00" in model开发者_如何学Python so even if i enter 100 it should automatically become $100.00


How to specify MaxLength for a textbox , Like MaxLenth="18"

You could pass additional html attributes to the TextBoxFor method:

<%= Html.TextBoxFor(x => x.SomeValue, new { maxlength = "18" })

How to Set the TextBox Format String as FormatString="$###,###,###,##0.00" in model so even if i enter 100 it should automatically become $100.00

You could use the [DisplayFormat] attribute:

[DisplayFormat(DataFormatString = "{0:$###,###,###,##0.00}", ApplyFormatInEditMode = true)]
public decimal? Value { get; set; }

and then:

<%= Html.EditorFor(x => x.Value) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜