What is the correct way to "#include file" in MVC?
3 answers
<%: Html.Partial("~/Views/foo/box.ascx") %>
or
<% Html.RenderPartial("~/Views/foo/box.ascx"); %>
or the best of them use the editor template (if this partial contains inputs for editing the properties of the view model):
<%: Html.EditorFor(x => x.MyModelProperty) %>
or a display template (if this partial contains only a display of the property of the view model):
<%: Html.DisplayFor(x => x.MyModelProperty) %>
and their Razor equivalence
@Html.Partial("~/Views/foo/box.ascx")
@{Html.RenderPartial("~/Views/foo/box.ascx");}
@Html.EditorFor(x => x.MyModelProperty)
@Html.DisplayFor(x => x.MyModelProperty)
+14