Copied to clipboard

Flag this post as spam?

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


  • Thomas 41 posts 121 karma points
    Aug 13, 2018 @ 07:14
    Thomas
    0

    How to find the exact child node from list of nodes in c#

    I'm new for umbraco and i want to find the exact child node from list of child nodes in c#

    how this possible in c#?

  • Ibrahim Nada 20 posts 166 karma points c-trib
    Aug 13, 2018 @ 07:49
    Ibrahim Nada
    0

    You Can Find it by ID

    var umbracoNode =Children.Single(x=>x.Id=<YourNodeID>);
    

    and if your not sure the node is there u can use "SingleOrDefault"

    var umbracoNode =Children.SingleOrDefault(x=>x.Id=<YourNodeID>);
    

    then check if umbracoNode != null

    hope that helps

    *NOTE: you can get Nodes ids in properties tab in the back office *

  • louisjrdev 107 posts 344 karma points c-trib
    Aug 13, 2018 @ 10:55
    louisjrdev
    0

    you could use:

    var node = Umbraco.TypedContentSingleAtXPath("//DocTypeAlias");
    

    or

    var node = nodes.Where(x => x.Content.DocTypeAlias == "YourDocTypeAlias");
    
Please Sign in or register to post replies

Write your reply to:

Draft