Is umbraco.NodeFactory still the way to go for user controls?
It's been a long time since I have developed Umbraco solutions.... Last time I did it, I used umbraco.presentation.nodeFactory, which is now replaced by umbraco.NodeFactory.
But having worked a bit with Razor in partial views, I'm wondering if there is also a way to use the whole DynamicNode / IPublishedContent in user controls as well.
This would give a more uniform codebase for the solution, and make easier to mantain.
In UserControls it's also best to use IPublishedContent. You can probably inherit from UmbracoUserControl which has all the helpers you need to use IPublishedContent.
Thanks. Does anyone have an example of how to get hold of some content. In my partial view I use Model.Content, but I can't seem to get hold of any object for getting the current page, or instantiating one e.g. from an ID.
If you inherit from UmbracoUserControl you have access to the UmbracoHelper (called Umbraco) so you can do Umbraco.AssignedContentItem to get the current node.
Is umbraco.NodeFactory still the way to go for user controls?
It's been a long time since I have developed Umbraco solutions.... Last time I did it, I used umbraco.presentation.nodeFactory, which is now replaced by umbraco.NodeFactory.
But having worked a bit with Razor in partial views, I'm wondering if there is also a way to use the whole DynamicNode / IPublishedContent in user controls as well.
This would give a more uniform codebase for the solution, and make easier to mantain.
Hello,
In UserControls it's also best to use IPublishedContent. You can probably inherit from UmbracoUserControl which has all the helpers you need to use IPublishedContent.
Jeroen
Thanks. Does anyone have an example of how to get hold of some content. In my partial view I use Model.Content, but I can't seem to get hold of any object for getting the current page, or instantiating one e.g. from an ID.
If you inherit from UmbracoUserControl you have access to the UmbracoHelper (called Umbraco) so you can do Umbraco.AssignedContentItem to get the current node.
Jeroen
Aha, "Umbraco" is the magic word. Thanks :-)
Hello,
Could you please mark a post as the solution if it helped you.
Jeroen
is working on a reply...