我有这个:
@Html.TextBoxFor(m => m.MyClass.MyValue, new { style = "width: 138px", id = "mTextBox", maxlength = 10 })
我可以帮您格式化内容。在哪里可以进行此操作?
谢谢,
我有这个:
@Html.TextBoxFor(m => m.MyClass.MyValue, new { style = "width: 138px", id = "mTextBox", maxlength = 10 })
@Html.TextBoxFor(model => model.INVOICE_DATE,"{0:MM/dd/yyyy}", new { maxlength = 10, style = "min-height:30px; min-height: 30px; border-color: green; " })
您可以使用
Html.TextBox("MyValue",String.Format('<your format>',Model.MyClass.MyValue))
我在类似这样的情况下使用了EditorFor,并在我的属性上添加了DisplayFormat属性。
在我看来:
<%: Html.EditorFor(model => model.StartDate)%>
在我的视图模型上
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime StartDate { get; set; }
@Html.TextBoxFor(model => model.Fecha, "{0:G}", new { @class="vld-required" })
Html.TextBoxFor(model => model.MyClass.TimeStamp, String.Format("{0:g}",Model.MyClass.TimeStamp))