Copied to clipboard

Flag this post as spam?

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


  • Mathias Valentin 60 posts 208 karma points
    Apr 13, 2016 @ 07:30
    Mathias Valentin
    0

    How to use variables with GetPropertyValue?

    Hi,

    How can I use variables to get properties on DynamicPublishedContent? I'm trying to do something like:

    string someVariable = "adress";
    
    <p>@CurrentPage.GetPropertyValue(someVariable);</p>
    

    This however is giving me the following error msg:

    CS1973: 'System.Collections.Generic.IEnumerable<Umbraco.Core.Models.IPublishedContent>' has no applicable method named 'GetProperty' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
    

    Thanks!

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 13, 2016 @ 07:50
    Kevin Jump
    100

    Hi

    I think you have to use the Typed Content properties to do that.

    try @Model.Content.GetPropertyValue(someVariable)

    Kevin

  • Samira 113 posts 452 karma points
    Apr 13, 2016 @ 08:05
    Samira
    1

    Hi,

    try this

    string someVariable = "adress";
    
    <p>@Model.Content.GetPropertyValue(someVariable)</p>
    

    hope this help

    Regards,

    Samira

Please Sign in or register to post replies

Write your reply to:

Draft