我有一个编辑器模板,在该编辑器模板中,我想调用具有相同模型的另一个编辑器模板(即嵌套),但似乎没有显示.
即.\ EditorTemplates\Template1.cshtml
@model foo
// insert code here to edit the default fields.
// display extra fields via another editor template.
@Html.EditorForModel("Template2") // or @Html.EditorFor(m => m, "Template2")
Run Code Online (Sandbox Code Playgroud)
和\ EditorTemplates\Template2.cshtml
@model foo
@Html.TextBoxFor(m => m.Name)
Run Code Online (Sandbox Code Playgroud)
我相信有人会质疑为什么?好吧,只有满足条件时才会显示嵌套模板(即@if(@ Model.IsConditionMet){....}),但为了简单起见,我将其从原型中删除了.