@inherits Dynamicweb.Rendering.ViewModelTemplate @Title("Partial view demo") @Description("Demo of how to render partial views") @Model.Title @* Use current model *@ @RenderPartial("partials/page.cshtml") @* Use any other model that inherits from ViewModelBase *@ @RenderPartial("partials/page-area.cshtml", this.Model.Area) @RenderPartial("partials/page-properties.cshtml", this.Model.PropertyItem) @RenderPartial("partials/page-cart.cshtml", this.Model.Cart) @functions { /// /// Renders a partial view using the current view model /// /// Relative path to a view model template, e.g. "partials/part.cshtml /// Output from rendering of the view model template string RenderPartial(string templatePath) { return RenderPartial(templatePath, this.Model); } /// /// Renders a partial view using the given view model /// /// The type of viewmodel. The type must inherit from Dynamicweb.Rendering.ViewModelBase /// Relative path to a view model template, e.g. "partials/part.cshtml /// Instance of a view model /// Output from rendering of the view model template string RenderPartial(string templatePath, T model) where T : Dynamicweb.Rendering.ViewModelBase { var template = new Dynamicweb.Rendering.Template(templatePath); template.SetViewModel(model); return template.Output(); } }