Umbraco - Get Node by ID programmatically

25,255

Solution 1

You can just do

var node = new Node(nodeId).

Took me a while to find it too!

Solution 2

Use this

umbraco.NodeFactory.Node headerNode = uQuery.GetNode(NodeId);

add namespace

using umbraco.NodeFactory;
Share:
25,255
autonomatt
Author by

autonomatt

Ecommerce Consultant - Director of Tronik Specializing in ecommerce websites Preferred languague C# Preferred technologies ASP.NET MVC, NHibernate, Castle Windsor, jQuery Fan of DDD, TDD, and Agile methods. Co-founder/organiser of Leeds Sharp We've gone on holiday by mistake. Are you the farmer?

Updated on July 21, 2022

Comments

  • autonomatt
    autonomatt almost 2 years

    Running Umbraco 4x I am creating a helper method in C# that I can recursively call to create child categories of a particular node (category).

    The method takes a parentNodeID as a parameter. I need to retrieve the properties of that parent node. I know I can use the static method Node.GetCurrent() but I'm looking for something like Node.GetNodeById(parentNodeID).

    I just can't see where this method lives. I know there is the umbraco.library.getNodeXMLbyId method, but does that give me the name property of the node?

    Me Umbraco N00b :)