Partial Rendering and Layout Pages for RazorFolderHostContainer

The RazorFolderHostContainer supports rendering external template in two ways:

  • @RenderPartial()
  • Layout Page Property

@RenderPartial()

You can render

Note that you can render partials, by specifying the virtual path for the partial relative to the to TemplateBasePath specified.

@RenderPartial("~/Partials/PartialComponent.cshtml",model)

Rendering Layout Pages

You can also use Layout pages with the RazorFolderHostContainer by specifying the Layout property in your view/template.

@inherits Westwind.RazorHosting.RazorTemplateFolderHost<RazorHostingTests.Person>
@{
    Layout = "~/_Layout.cshtml"
}
<h3>Hello @Model.Firstname</h3>
<p>
this is my page content rendered at @DateTime.Now.
</p>

The View Page then:

@inherits Westwind.RazorHosting.RazorTemplateFolderHost<RazorHostingTests.Person>

<h1>Layout Page Header</h1>
<hr />

@RenderBody()

<hr/>
&copy; West Wind Technologies, 2010-@DateTime.Now.Year

Note that you should use the same model your are passing to the content page as a parameter in the layout page - if you plan on accessing model content.


© West Wind Technologies, 2018 • Updated: 05/29/17
Comment or report problem with topic