我有一个编辑器模板,在该编辑器模板中我想调用另一个具有相同模型(即嵌套)的编辑器模板,但它似乎没有显示。
IE。\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")
和 \EditorTemplates\Template2.cshtml
@model foo
@Html.TextBoxFor(m => m.Name)
我相信有人会问为什么?好吧,只有在满足条件时才会显示嵌套模板(即 @if (@Model.IsConditionMet) { .... } ),但为了简单起见,我将其从原型中删除。