Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
I have tried many ways to no avail. Thanks
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;
Regards
Marc
Thanks. This did the trick!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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.
I have tried many ways to no avail. Thanks
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;
Regards
Marc
Thanks. This did the trick!
is working on a reply...