1

Here's the item from the View

 @Html.EditorFor(Function(model) model.BirthDate)

Here's the code from the EditorTemplate (simplified)

@ModelType Date?
<span>
    @Html.TextBox("", Model)
</span>

but the output doesn't have the span tags.

The datatype of the model.BirthDate is Date?

The folder structure is

  • Views
    • Shared
      • EditorTemplates
        • Date.vbhtml

EDIT

Ok, so after some digging, I found that if I add <UIHint("Date")> to my BuddyClass, then the template works.

So my "new" question would be... why wouldn't it pick this up by default?

4

1 回答 1

1

出色地。@Brad Wilson 在asp.net 论坛上回答了我的问题。

默认模板名称基于 CLR 类型名称,在本例中为 DateTime。“日期”是 VB 中的快捷方式名称,而不是真正的类型名称(很像 C# 中的“int”实际上是 CLR 的“Int32”的快捷方式)

现在我懂了。谢谢@布拉德

于 2010-11-25T23:44:08.947 回答