Is it possible to specify the full path of a Display or Editor template?
For example, I have the following model:
public class ParentModel
{
public class ChildModel { get; set; }
}
I have a ParentController
and a ChildController
and I would like to put the Child display template view in the Views/Child/DisplayTemplates/ChildModel.cshtml and the ParentModel.cshtml view in Views/Parent/DisplayTemplates/ParentModel.cshtml.
Right now it can't find the Child display template because it is looking in Views/Shared and Views/Parent.
Is it possible to specify the full path of a Display Template or write an HtmlHelper that can specify the folder(s) to look in?
I have figured out a way that works with only one slight drawback:
@Html.DisplayFor(model => model.Child, "Child/ChildModel")
I created the following folder:
Views\Shared\DisplayTemplates\Child
and placed ChildModel.cshtml
in the folder. The drawback to this is that it no longer uses the model name to determine the template name and I imagine it is probably ignoring UIHint
as well, but it does allow me to organize my Shared display templates a little better.