I have a razor script in Umbraco that is quite complicated and I want it to display a macro in it at some point.
A macro called SuggestionBox is actually a user control (.ascx), and traditionally it refers to a template using
<umbraco:macro Alias="SuggestionBox" language="cshtml" runat="server"></umbraco:macro>
But now I need to call it from a razor script, so I tried;
@Html.Raw(umbraco.library.RenderMacroContent("SuggestionBox", Model.Id))
and:
@RenderPage("SuggestionBox")
No luck, as far as I am sure that I am wrong.
I read somewhere that this may not be feasible if the page is wrapped on the main page.
It works if I add it to the template, as I have traditionally:
<umbraco:macro Alias="EventsRenderer" language="cshtml" runat="server"></umbraco:macro> <div class="talkingPointPanel"> <h3><umbraco:Item field="talkingPoinstSuggestionText" runat="server"></umbraco:Item></h3> <umbraco:macro Alias="SuggestionBox" language="cshtml" runat="server"></umbraco:macro> </div>
Where EventsRenderer displays a page that should ideally contain a hint.
using
@Html.Raw(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"SuggestionBox\" />", Model.Id))
Gives me this error:
Any ideas?
source share