Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • fed 199 posts 70 karma points
    Mar 14, 2011 @ 13:21
    fed
    0

    Output Razor from template

    Sometimes for some specific controls/listings like TopMenu I dont really want to create a Macro. Instead I usually create usercontrols for these kinds of stuff.

    So my question is bascially, is it possible to output a Razorscript directly from the masterpage/template without creating a macro? (Using it like a usercontrol)

    I have tried, but I cant seem to get it working, or maybe I am missing some references.

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 14, 2011 @ 13:31
    Jonas Eriksson
    2

    Hi, do you mean like this?

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
      <umbraco:Macro language="razor" runat="server">
        @RenderPage("~/MacroScripts/myscript.cshtml")
      umbraco:Macro>
    asp:Content>

    But macros are fine, aren't they?

  • fed 199 posts 70 karma points
    Mar 14, 2011 @ 13:35
    fed
    0

    Yeah, that is exactly what I was looking for..

    I just thought it could be done without the umbraco macro control, but that might not be possible..

    Thanks..

  • Comment author was deleted

    Mar 14, 2011 @ 15:55
  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Mar 14, 2011 @ 17:53
    Sebastiaan Janssen
    1

    You can just (as is shown in Tim's video) use the script without having to call a file:

    <umbraco:Macro language="razor" runat="server">
      <h2>@Model.Name</h2>
    </umbraco:Macro>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies