Copied to clipboard

Flag this post as spam?

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


  • Mustufa Baig 19 posts 41 karma points
    Jul 07, 2011 @ 21:53
    Mustufa Baig
    0

    Cannot able to access custom properties

    Hi there

    I am getting the error loading razor script when try to access a custom property on "item":

    error CS1061: 'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'someCustomProperty' and no extension method 'someCustomProperty'accepting a first argument of type 'umbraco.MacroEngines.DynamicNode' could be found (are you missing a using directive or an assembly reference?) 

    Although when i debug and hover over the 'item" object i can see the property in the item.PropertiesAsList collection.

    @{

    var siteMapNode = model.NodeById(1046).GetChildrenAsList.Items.SingleOrDefault(s => s.Name == "en");

    }

     

    <

     

     

    ul class="floatL" id="mainNav">

    @

     

    foreach (DynamicNode item in siteMapNode.GetChildrenAsList)

    {

     

    var linkTitleImagesData = item.someCustomProperty; //

     

    <li>

     

    <a href="" class="btn" style="display: inline;"><img width="89" height="44" alt="Nutrition" src="img/en/navBtns/nutri.png" class="btn"></a>

     

    <a href="" class="btnOver" style="display: none;"><img width="89" height="44" alt="Nutrition" src="img/en/navBtns/nutri_on.png"></a>

     

    </li>

    }

     

    Any idea what am i missing?

     

    Thanks

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jul 11, 2011 @ 10:26
    Dan Diplo
    1

    Just a guess, but try changing:

    foreach (DynamicNode item in siteMapNode.GetChildrenAsList)

    to

    foreach (dynamic item in siteMapNode.Children) 

    Basically you need the nodes to be a dynamic type to access custom properties directly. 

Please Sign in or register to post replies

Write your reply to:

Draft