Copied to clipboard

Flag this post as spam?

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


  • Edgar Rasquin 326 posts 925 karma points
    Oct 06, 2022 @ 08:44
    Edgar Rasquin
    0

    Cannot bind source typeContentBlockViewModel to model type IPublishedContent

    Hi there,

    I am trying to render a partialView within a partial that uses the

    IContentBlockViewModel
    

    enter image description here

    Since my Breadcrumbs.cshtml partial inherits from

    UmbracoViewPage
    

    I get the following error:

    Cannot bind source type Perplex.ContentBlocks.Rendering.ContentBlockViewModel`1[[Umbraco.Web.PublishedModels.HeaderBlock2, fmpool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to model type Umbraco.Core.Models.PublishedContent.IPublishedContent.
    

    Is there a solution?

  • Daniël Knippers 153 posts 1117 karma points MVP 2x c-trib
    Oct 06, 2022 @ 09:08
    Daniël Knippers
    100

    So your Breadcrumbs.cshtml uses IPublishedContent as model whereas you pass in the IContentBlockViewModel<>. That should indeed not work since IContentBlockViewModel does not implement IPublishedContent. Neither does Model.Content as that is IPublishedElement.

    I suppose what you want is simply pass in the current PublishedContent of the request. You can change @model IContentBlockViewModel<HeaderBlock2> into @inherits UmbracoViewPage<IContentBlockViewModel<HeaderBlock2>> (so you get access to the Umbraco property), then update your partial call to:

    Html.RenderPartial("~/Views/Partials/Breadcrumbs.cshtml", Umbraco.AssignedContentItem)

  • Edgar Rasquin 326 posts 925 karma points
    Oct 06, 2022 @ 09:22
    Edgar Rasquin
    0

    Daniël,

    you are an absolute STAR! Thank you so much for this instant solution.

    Have a great day

Please Sign in or register to post replies

Write your reply to:

Draft