Get Umbraco Certified in October

5 courses in 4 different countries across 2 continents leaves no excuse.

Attend courses in the Netherlands, UK, USA and at Umbraco HQ in Denmark.

See the schedule and read more about our training here.

Copied to clipboard

Flag this post as spam?

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

  • Tom 610 posts 745 karma points
    Jul 21, 2011 @ 04:15

    Model not being carried through to render page?

    Hi Guys,

    just trying to do the following I have a cshtml page called PageTitle.cshtml it's contents are:

    @if (@Model.pageTitle != null)

      if(Model.pageTitle.ToString().EndsWith("| Company Name"))
        @Html.Raw(Model.pageTitle " | Company Name")
      @Html.Raw(Model.Name " | Company Name")


    and then in my template am calling it like so:

    <title><umbraco:Macro runat="server" language="cshtml">@using umbraco.MacroEngines;@RenderPage("/macroScripts/PageTitle.cshtml");</umbraco:Macro></title>


    <meta property="og:title" content="@RenderPage("/macroScripts/PageTitle.cshtml")" />


    unfortunately @Model.pageTitle is not being picked up..

  • Alex 135 karma points
    Jul 21, 2011 @ 09:31

    You can't use @RenderPage directly in your template (like you have done in the meta tag) because the Template page is not a Razor cshtml file.

    Also, you can reference a cshtml file directly from a Macro tag without calling RenderPage, like this:

    <umbraco:Macro FileLocation="~/macroScripts/PageTitle.cshtml" runat="server" />

    Hope that helps.


Please Sign in or register to post replies

Write your reply to:

Draft is the community mothership for Umbraco, the open source cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.3.0