Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Adrian Wu 53 posts 266 karma points
    Jul 31, 2018 @ 23:02
    Adrian Wu

    Can I use @Html.Partial("FooterPartial") with a doc type in Master.cshtml ??

    Hi guys, I want to bind my FooterPartial partial view to my FooterColumns document type and use the FooterPartial in Master.cshtml. enter image description here

    But the home page is giving me "Cannot bind source content type Umbraco.Web.PublishedContentModels.Home to model type Umbraco.Web.PublishedContentModels.FooterColumns."

    I think the @RenderBody() in the Master.cshtml is rendering the Home Doc type.

    Is there anything I can do? I just want the content editor able to edit the footer which is rendered in Master.cshtml



  • Chriztian Steinmeier 2793 posts 8776 karma points MVP 7x admin c-trib
    Aug 01, 2018 @ 04:55
    Chriztian Steinmeier

    Hi Adrian,

    Yes, you should be able to do that.

    In the call to Html.Partial() you can explicitly specify the Model as a second argument, so something like this:

    var siteRoot = Model.Site();
    var footer = siteRoot.Children<FooterColumns>().FirstOrDefault();
    @Html.Partial("FooterPartial", footer)

    (This assumes your views inherit from UmbracoViewPage and that your FooterColumns document is a child of the "site" node, e.g. Home).

    Hope that helps,


Please Sign in or register to post replies

Write your reply to: