I'm using Umbraco.Content() and I need to get a propertyvalue.
In version 7 I could just write:-
page1.GetPropertyValue
but in Umbraco 8 I don't seem to have this option anymore. I've used Model.Value() in other parts of v8 but it's not available for the page I'm working on Umbraco.Web.Mvc.UmbracoViewPage
Any ideas how I can pull a custom property from Umbraco.Content in v8?
Umbraco.Content() returns either a single IPublishedContent or an IEnumerable<IPublishedContent> depending on what you pass into it.
The method .Value, I believe, is an extension method for the IPublishedContent interface so should be readily available if you have the standard web.config in your views folder as this should have all the name spaces defined. If you have the single object returned it should be there, else if you have had an IEnumerable returned you'll need to loop around it to get each individual element and call .Value on that.
It is possible that you are missing the namespace however, in which case you need to ensure that you are referencing the Umbraco.Web namespace for it to be available.
Custom property from Umbraco.Content in v8
Hello,
Hopefully, this is an easy one for somebody here.
I'm using Umbraco.Content() and I need to get a propertyvalue.
In version 7 I could just write:-
page1.GetPropertyValue
but in Umbraco 8 I don't seem to have this option anymore. I've used Model.Value() in other parts of v8 but it's not available for the page I'm working on Umbraco.Web.Mvc.UmbracoViewPage
Any ideas how I can pull a custom property from Umbraco.Content in v8?
Thanks
Hi Paul,
It should be available.
Umbraco.Content()
returns either a singleIPublishedContent
or anIEnumerable<IPublishedContent>
depending on what you pass into it.The method .Value, I believe, is an extension method for the IPublishedContent interface so should be readily available if you have the standard web.config in your views folder as this should have all the name spaces defined. If you have the single object returned it should be there, else if you have had an IEnumerable returned you'll need to loop around it to get each individual element and call .Value on that.
It is possible that you are missing the namespace however, in which case you need to ensure that you are referencing the
Umbraco.Web
namespace for it to be available.Nik
Hi Nik,
Thanks for the reponse, it was the missing namespace that I needed Umbraco.Web. Can't believe I overlooked this one.
Cheers Paul
is working on a reply...