Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:57:15+00:00 2026-06-14T22:57:15+00:00

I have a razor script in Umbraco that is quite complex and I want

  • 0

I have a razor script in Umbraco that is quite complex and I want at some point of it to render a macro in it.

The macro which is called SuggestionBox is actually a user control (.ascx) and traditionally this is referenced on the template using

<umbraco:macro Alias="SuggestionBox" language="cshtml" runat="server"></umbraco:macro>

But now I need to call it from the razor script instead so I tried;

@Html.Raw(umbraco.library.RenderMacroContent("SuggestionBox", Model.Id))

as well as:

@RenderPage("SuggestionBox")

No luck so far as I’m sure I’m using these wrongly.

I read somewhere it might be infeasible if the page is wrapped in a masterpage.

It works if I add it to the Template like I traditionally would:

 <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 renders the page that should ideally contain the SuggestionBox.

using

@Html.Raw(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"SuggestionBox\" />", Model.Id))

Gives me this error:

<!-- Error generating macroContent: 'System.Web.HttpException (0x80004005): HtmlForm cannot render without a reference to the Page instance.  Make sure your form has been added to the control tree.

   at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)

   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)

   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

   at umbraco.presentation.templateControls.Macro.Render(HtmlTextWriter writer)

   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)

   at umbraco.library.RenderMacroContent(String Text, Int32 PageId)' -->

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:57:17+00:00Added an answer on June 14, 2026 at 10:57 pm
    <umbraco:Macro runat="server" language="cshtml">@{
    
    HtmlTextWriter writer = new HtmlTextWriter(this.Output);
    var navigation = new umbraco.presentation.templateControls.Macro();
    
    navigation.Alias = "Navigation";
    navigation.MacroAttributes.Add("ulclass", "art-vmenu");
    navigation.MacroAttributes.Add("level", 2);
    
    navigation.RenderControl(writer);   }</umbraco:Macro>
    

    Try something like this. It works for me … I have made a Navigation macro. Be Aware though your variables should be given in toLower, if caps are used, the parameters will not come through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script based on .NET & Razor that renders on a webpage
I have table that is built dynamically with Razor in MVC. I want to
I have asp.net mvc application, that uses razor view engine. I want to send
I have a loop in razor which generates a template a number of times.
I have developed a website using Razor (Microsoft WebMatrix) and now I want to
I have a action link on my MVC3 razor view. Which have a action
I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When
Have to embed javascript code block with <script type='text/javascript'> ... </script> But Razor code
With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
I am developing a web site using MVC 3 razor, in which I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.