我想爲我的任何模型中的每個datatime對象配置EditorFor模板。對於DateTime對象的這個簡單的EditorTemplate問題
我得到這個錯誤:
\EditorTemplates\DateTime.cshtml(1): error CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'TextBox' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
這裏就是整個代碼,就是所謂的EditorTemplate,在EditorTemplates文件夾DateTime.cshtml場所內。
任何想法?
這就是我所說的,我認爲:
<div class="editor-label">
@Html.LabelFor(model => model.DateOfBirth)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateOfBirth)
@Html.ValidationMessageFor(model => model.DateOfBirth)
</div>
這是自定義EditorTemplate我做:
@Html.TextBox("", Model, new { @class = "date-selector" });
THE EDITOR IS WORKING
基本上,在我的模型每DateTime對象,我想補充的類「日期選擇器」到該HTML元素。這是用於jQueryUI的目的。
我在做什麼錯?
看來我只是把模型轉換爲(日期時間)模型。 –