Copied to clipboard

Flag this post as spam?

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


  • BarrySlisk 15 posts 35 karma points
    Aug 02, 2012 @ 10:22
    BarrySlisk
    0

    How to get properties of umbraco.NodeFactory.Node

    Yes, this should be simple...

    <p>type: @MyItem.GetType().ToString()</p>

    This returns umbraco.NodeFactory.Node

    I tried to get the name to see if I got the right node.

    @MyItem.GetProperty("Name").Value

    This fails when saving in Umbraco:

    'object' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

    @MyItem.GetProperty("Headline").Value this is the property I'm really interested in but this also fails. This is a TextString defined on the document type.

     

     

    Bonus question :)

    Can I convert umbraco.NodeFactory.Node to DynamicNode?

     

     

     

     

  • BarrySlisk 15 posts 35 karma points
    Aug 02, 2012 @ 10:51
    BarrySlisk
    0

    I can get the name of the node like this of course (it was the node I expected so the other properties exist):

    @MyItem.Name

  • BarrySlisk 15 posts 35 karma points
    Aug 02, 2012 @ 12:21
    BarrySlisk
    0

    Ok, I found out how to convert to dynamic. For other people in the future getting here, it's via the constructor of new DynamicNode().

    This means that I can get my properties by just dotting.

    Are there any advantages/disadvantages of non-dynamic nodes? Should I not just convert to dynamic always (for eaxample after .where clauses with lambda)?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies