Im currently making usercontrol for umbraco that takes all Nodes indside a Node names “Features”…
And it all works perfekt, until i wanted to get content from the “Content Picker” property (named linkToPage).
When i tried to use GetProperty("linkToPage").Value, I got an error about it being an object.
So i then added it to a var and debugged, and saw it returned somthing a bit strange…
var linkIdVar = child.GetProperty("linkToPage");
Returns:
- linkIdVar {1081} umbraco.interfaces.IProperty {umbraco.NodeFactory.Property}
- [umbraco.NodeFactory.Property] {1081} umbraco.NodeFactory.Property
Alias "linkToPage" string
Value "1081" string
+ Version {00000000-0000-0000-0000-000000000000} System.Guid
+ Non-Public members
Alias "linkToPage" string
Value "1081" string
+ Version {00000000-0000-0000-0000-000000000000} System.Guid
And i can’t seem to get the Value to a Int without getting error about it being an object…
So does anyone know how to get arround this, or know a better way to get the page from a Content Picker?
I think you might need to unbox the value to an integer, like so:
However, if the content of the property value is not an integer, but a string, as the debugging information seems to indicate, then you need to convert to an integer, like so: