Created
March 27, 2013 18:55
-
-
Save munr/5257006 to your computer and use it in GitHub Desktop.
Umbraco - Render .Net User Control (ascx) macro with Razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @* | |
| 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