I am using EditorFor()
helper to render edit template in my view and I would like to call the DisplayFor()
inside this template to render out the D
I am afraid that the only way is to use a partial:
<%= Html.Partial("~/Views/Home/DisplayTemplates/Client.ascx", Model) %>
It can be debatable if it is a good idea to template complicated objects, or if my approach to nested templates is a hack or not. The advantage of this is having a single template for the parent and child can both have templates rather than having to choose/use partial views.
All that aside, templated views can be nested, if you use a partial view as an go between.
The outside template will have something like below where you want to place the inner template:
Html.RenderPartial("SharedDisplayGoBetweenForFoo", item);
The shared partial would look like this:
@model Foo
@Html.DisplayFor(a => a);
The inner template would then be called and would look like any other.