var videoPage = page.GetPropertyValue<IPublishedContent>("video");
When you call page.GetPropertyValue(alias), the value is returned as an object. Since the compiler doesn't know what sort of value will actually be returned, you can't do much more than convert the value to a string.
Calling GetPropertyValue<T>(alias) instead returns a T, so the compiler knows what you're expecting and can let you access its properties and methods.
Unable to access node properties
Hi all,
I have a node which I'm trying to access the media picker property off, so I'm using the below:
So I'm getting the current page ID and converting that to TypedContent and then getting the property value (video) and loading that into videoPage.
I can see that the variable has all of the properties I would expect but I can't 'get' them.
i.e. I would have thought that I could use @videoPage.Id but the Id value isn't exposed (none of the properties are).
Any ideas anyone?
Try this:
When you call
page.GetPropertyValue(alias)
, the value is returned as anobject
. Since the compiler doesn't know what sort of value will actually be returned, you can't do much more than convert the value to a string.Calling
GetPropertyValue<T>(alias)
instead returns aT
, so the compiler knows what you're expecting and can let you access its properties and methods.is working on a reply...