【发布时间】:2017-01-25 16:34:49
【问题描述】:
我有一个从那里我想有一个开始和结束时间的编辑器。
所以我在路径“Views/Shared/EditorTemplates/Time.cshtml”中创建了一个EditorTemplate。
@model string
@{
var htmlAttributes = this.GetControlHtmlAttributes();
htmlAttributes.AddClass("time");
htmlAttributes.AddAttribute("style", "background-color: fuchsia");
}
@Html.TextBoxFor(m => m, htmlAttributes: htmlAttributes)
在我看来,我叫
<td>
@Html.EditorFor(m => m[i].kal_von)
</td>
<td>
@Html.EditorFor(m => m[i].kal_bis)
</td>
(请注意:如果我这样称呼它是行不通的:
<td>
@Html.EditorFor(m => m[i].kal_bis, "Time")
</td>
)
模型看起来像这样:
[StringLength(5)][DataType(DataType.Time)][DataMember(EmitDefaultValue = false)]
[DisplayNameAttribute("d_kal_termin.kal_von")]
public string kal_von { get; set; }
[StringLength(5)][DataType(DataType.Time)][DataMember(EmitDefaultValue = false)]
[DisplayNameAttribute("d_kal_termin.kal_bis")]
public string kal_bis { get; set; }
谢谢!!
【问题讨论】:
标签: c# asp.net razor mvc-editor-templates