Possible to get nodes in code behind?
# help-with-umbraco
t
Hi I have a class that does NOT inherit any Umbraco controllers or anything when using Umbraco 13. What I need to do is get a list of nodes using C# code inside this class. I know how to get this by using Razor but I can't figure out which classes/interfaces I need to pull the data from the parent node. Does anyone know if this is possible? Thx
k
When you say "the parent node" it sounds that there is a "current Umbraco context" the class should be aware of. In that case, the easiest way is probably to register your class with DI and have the DI inject an Umbraco context accessor into your class. Or you could pass an Umbraco context from a controller to your class when creating an instance of the class.
t
Perfect that explained it well after I saw an example. Thanks
25 Views