Copied to clipboard

Flag this post as spam?

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


  • Thomas 43 posts 123 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 22 posts 168 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");
    
  • 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