Copied to clipboard

Flag this post as spam?

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

  • UmbracoTests 27 posts 178 karma points
    19 days ago

    Getting a value from getproperty getvalue

    How do you access these values for example Colour in this image? To get the values I did evt.Getproperty("category").GetValue(). I am also doing this in a controller so I can pass the value to the view.

    enter image description here

    I have tried many ways to no avail. Thanks

  • Marc Goodson 2046 posts 13491 karma points MVP 8x c-trib
    1 week ago
    Marc Goodson

    Hi UmbracoTests

    Sounds like you have an Event that can pick a Category, which is another Umbraco content item and in this Category there is a colour property?

    A lot depends on if you are using Modelsbuilder and strongly typed models or just the underlying IPublishedContent representation of Umbraco items...

    Anyway if evt is your event model you should be able to get the picked category via

    var category = evt.Value<IPublishedContent>("category");

    (unless the picker allows multiple categories then it would be... & lt;IEnumerable<IPublishedContent>>)

    When you have your category you can then access its properties via

    var colour = category.Value<string>("colour");

    If you are using Modelsbuilder then you would be able to cast your picked item into the associated content model eg

    var category = evt.Value<IPublishedContent>("category") as Category; var colour = category.Colour;



  • UmbracoTests 27 posts 178 karma points
    5 days ago

    Thanks. This did the trick!

Please Sign in or register to post replies

Write your reply to: