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) %>
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论