You can still use the @Umbraco helper with WebForms, that is what the Macro Partial View is mainly for, it supersedes the the Razor Macro.
In fact you can take a existing Razor macro code, place into a new Macro Partial View, make the required updates, e.g. @Library to @Umbraco and then switch the Macro itself from the Scripting File to the new Macro Partial View and not even need to change the MasterPage template at all.
UmbracoHelper in Razor using @Umbraco?
Simple, as the subject says...
I get validation errors when trying to save a macroScript containing things such as:
Am I missing something?
You cannot just:
Hi Kris,
To use @Umbraco you need to be using either a MVC View (template), a Partial View or a Macro Partial View.
DynamicNodeContext is used by the legacy "Razor Macros", if have to use a Razor Macro, then the helper is @Library
MVC documentation is here but essentially don't use the "Scripting Files" tree unless you need to for legacy support.
Does that help?
Jeavon
Hi Jeavon,
That indeed confirms what I was afraid of.
I' m working on a site still using MasterPages instead of MVC and a whole bunch of Scripting Files...
Maybe it' s about time to overhaul the whole thing :s
You can still use the
@Umbraco
helper with WebForms, that is what the Macro Partial View is mainly for, it supersedes the the Razor Macro.In fact you can take a existing Razor macro code, place into a new Macro Partial View, make the required updates, e.g. @Library to @Umbraco and then switch the Macro itself from the Scripting File to the new Macro Partial View and not even need to change the MasterPage template at all.
Great stuff!
Somehow I wasn't aware this was possible...
Thanks!
is working on a reply...