Skip to content

Instantly share code, notes, and snippets.

@munr
Created March 27, 2013 18:55
Show Gist options
  • Select an option

  • Save munr/5257006 to your computer and use it in GitHub Desktop.

Select an option

Save munr/5257006 to your computer and use it in GitHub Desktop.
Umbraco - Render .Net User Control (ascx) macro with Razor
@*
Render Umbraco macro from within Razor macro
http://stackoverflow.com/questions/10689284/umbraco-render-net-user-control-ascx-macro-with-razor
Yes, it looks like a server control but it does work from a Razor macro.
The example below is for rendering a Contour form
*@
<umbraco:Macro runat="server" language="cshtml">
@{
var writer = new HtmlTextWriter(Output);
var navigation = new umbraco.presentation.templateControls.Macro();
navigation.Alias = "umbracoContour.RazorRenderForm";
navigation.MacroAttributes.Add("formguid", "FORM-GUID-HERE");
navigation.RenderControl(writer);
}
</umbraco:Macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment