Copied to clipboard

Flag this post as spam?

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


  • Gert 81 posts 288 karma points
    Nov 08, 2016 @ 08:39
    Gert
    0

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Id'

    This code worked perfectly fine in Umbraco 7.3.

    var image = Umbraco.TypedMedia( ( int )CurrentPage.BannerBackgroundImage.Id );
    

    BannerBackgroundImage is of data type Media Picker.

    In a clean Umbraco 7.5.4 install I get the following Exception (RuntimeBinderException).

    'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Id'

    Umbraco.ModelsBuilder.Enable is set to false in the web.config.

    How should I solve this?

    Thanks! Gert.

  • Gert 81 posts 288 karma points
    Nov 08, 2016 @ 10:56
    Gert
    0

    Hi,

    The property BannerBackgroundImage of type media picker apperantly returns a collection??

    When I go the the Media Picker data type and I check the option, "Pick multiple items", save it, uncheck it and save it again then the media picker property won't return a collection but instead a single (dynamic) Umbraco.Web.Models.PublishedContentWithKeyBase which should be casted to IPublisheContent.

    So the

    var image = Umbraco.TypedMedia( ( int )CurrentPage.BannerBackgroundImage.Id );
    

    Shoud be

    IPublishedContentimage = Umbraco.TypedMedia( ( int )CurrentPage.BannerBackgroundImage.Id );
    

    Otherwhise calls to GetPropertyValue() and GetCropUrl() ... throw an exception: 'Umbraco.Web.Models.PublishedContentWithKeyBase' does not contain a definition for 'GetCropUrl'

    What is also strange is that the call image.GetPropertyValue( "umbracoWidth" ); returns a string now instead of an integer. Any idea why this is changed in Umbraco 7.5?

    Regards, Gert.

Please Sign in or register to post replies

Write your reply to:

Draft