Copied to clipboard

Flag this post as spam?

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


  • serhio 22 posts 82 karma points
    Apr 21, 2015 @ 18:46
    serhio
    0

    Umbraco: x.GetPropertyValue(myProp) vs x.myProp

    I use Umbraco v4, but think this should be a common problem.

    I have a generic property "myNode" of "Content Picker", that should obtain a DynamicNode...

    so doying myObj.myNode I obtain the node itself... so can use myObj.myNode.Url

    Doying the myObj.GetPropertyValue("myNode") I obtain the ... string ID value of the node... so can't anymore do myObj.GetPropertyValue("myNode").Url (string does not have Url property)

    I can't use directly myObj.myNode, because the name is "dynamic" (the same function should use "your"+"Node" or "their"+"Node" upon conditions - the example is very aproximative, but hope the idea is clear)...

    I even did myObj.GetPropertyValue<DynamicNode>("myNode"), but the result was the same: "8124" (the node id)

    So, how to obtain the real property value, not just string representation of it?

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 21, 2015 @ 21:40
    Alex Skrypnyk
    0

    Hi Serhio,

    You can only get node by yourself like that:

    var nodeId = myObj.GetPropertyValue<int>("myNode");
    var node = Umbraco.TypedContent(nodeId);
    var url = node.Url;
    

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft