开发者

Why isn't my EditorTemplate firing?

开发者 https://www.devze.com 2023-01-27 13:10 出处:网络
Here\'s the item from the View @Html.EditorFor(Function(model) model.BirthDate) Here\'s the code from the EditorTemplate (simplified)

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

精彩评论

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