开发者

Why isn't my EditorTemplate firing?

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?


Well. @Brad Wilson answered my question over at the asp.net forums.

The default template name is based on the CLR type name, in this case DateTime. "Date" is a shortcut name in VB, not the real type name (much like "int" in C# is really a shortcut for CLR's "Int32")

Now I get it. Thanks @Brad

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜