Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 936 posts 2571 karma points
    Oct 28, 2015 @ 13:37
    Claushingebjerg
    0

    Umbraco.Web.Models.PublishedContentBase' does not contain a definition for 'GetPropertyValue'

    Im using nested content on 7.3. Using the example form the docs:

    @{
         var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("eksempel");
         foreach(var item in items) {
         <p>@item.GetPropertyValue("kunden")</p>
           }
     }
    

    Replacing Model with CurrentPage as im directly on a template. But i get the following error:

    [RuntimeBinderException: 'Umbraco.Web.Models.PublishedContentBase' does not contain a definition for 'GetPropertyValue']

    Any idea why?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2015 @ 13:39
    Lee Kelleher
    0

    Hi Claus,

    The GetPropertyValue extension method is under the "Umbraco.Web" namespace, my guess would be that the Partial View can not resolve it, so would need to be included at the top...

    @using Umbraco.Web
    

    I hope this helps?

    Cheers,
    - Lee

  • Claushingebjerg 936 posts 2571 karma points
    Oct 28, 2015 @ 13:43
    Claushingebjerg
    0
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Umbraco.Web
    

    Didn't do it. I can use:

    @Umbraco.Field(item, "kunden")
    

    though

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2015 @ 13:48
    Lee Kelleher
    100

    Hmmm, strange.

    The PublishedContentBase inherits from IPublishedContent, so with the "Umbraco.Web" namespace reference, it should recognise the GetPropertyValue extension method.

    On a side-note, this isn't really related to Nested Content, (since you haven't actually got the value from Nested Content yet).

    Cheers,
    - Lee

  • Claushingebjerg 936 posts 2571 karma points
    Oct 28, 2015 @ 13:50
    Claushingebjerg
    0

    Hmm ok, well i got the data i needed with

    @Umbraco.Field(item, "kunden")
    

    Thats the main point. Thanks anyway :)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 28, 2015 @ 13:53
    Lee Kelleher
    0

    I thought the problem was with the line before the for-loop, with CurrentPage?

    Anyway, cool that you've got it sorted :-)

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft