Converting old Razor scripts to MVC Partial views macro files
Hey,
I've searched but haven't find - any good tutorial how to convert my old Razor scripts to MVC Partial views macro files? (U 7.x)
In the "old" Razor files I'm using a lot
@using umbraco.NodeFactory;
dynamic NAME_node = Library.NodeById(1xxx);
etc.
Not sure whether this the reason for the errors?
Looking for a good guide to the new world of MVC - how to convert the old Razor script to MVC. Using 7.4.2
If I choose the "old" Razor - things work. Once I change to the new partial view (which is the same code - just did copy-paste from the directory on the server, to the new "MVC Partial views macro files" on the CMS - it's suddenly doesn't work.
Converting old Razor scripts to MVC Partial views macro files
Hey, I've searched but haven't find - any good tutorial how to convert my old Razor scripts to MVC Partial views macro files? (U 7.x)
In the "old" Razor files I'm using a lot @using umbraco.NodeFactory;
dynamic NAME_node = Library.NodeById(1xxx);
etc. Not sure whether this the reason for the errors? Looking for a good guide to the new world of MVC - how to convert the old Razor script to MVC. Using 7.4.2 If I choose the "old" Razor - things work. Once I change to the new partial view (which is the same code - just did copy-paste from the directory on the server, to the new "MVC Partial views macro files" on the CMS - it's suddenly doesn't work.
Please advise. Thanks :)
Have you checked out the documentation? Specifically have a look at:
https://our.umbraco.org/documentation/Reference/Templating/Mvc/
https://our.umbraco.org/documentation/Reference/Querying/
A quick rule of thumb is that you replace Library with the Umbraco Helper. So where you had:
you would replace with:
or for strongly-typed (recommended) you would use:
The latter returns details as IPublishedContent which is the equivalent of Node.
is working on a reply...