I have a hierarchy of开发者_运维技巧 Models I need to render out editors for.
I want to have a nice ViewModel that contains all the info needed for each part of the hierarchy to render itself and have that ViewModel get passed down the chain of templates.
I have strongly typed View to that ViewModel, and I can get to the first level of nesting fine:
MyView.cshtml:
@model MyViewModel
@Html.EditorFor(x => x, "ViewTemplateA", "ViewTemplateA")
Within EditorTemplates/ViewTemplateA.cshtml:
@model MyViewModel
@Html.EditorFor(x => x, "ViewTemplateB", "ViewTemplateB")
---works OK up to here, ViewTemplateA gets rendered--
EditorTemplates/ViewTemplateB.cshtml:
@model MyViewModel
...etc...
-- ViewTemplateB never gets called. If I change it's @model
to something else, and pass in a different object to match, such as x => x.SubModel
, it gets called.
Any ideas??
精彩评论