Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 432 posts 1025 karma points
    Apr 14, 2013 @ 23:11
    Ayo Adesina
    0

    Why can't I use Razor?

    Hey guys,

    I'm working on my first umbraco 6 Project its fairly simple, just a one page website, with it's contents controled by umbraco.

    So far its not going to badly apart from one major thing, I don't seem to be able to use Razor syntax, for example,

    <p class="par-name"><umbraco:Item field="subTitle" runat="server" /></p> this seems to work,

    but....

    <p class="par-name">@Umbraco.Field("subTitle");</p>

    Just writes the  '@Umbraco.Field("subTitle")' to the browser.

    Can anyone shed any light on this? What am I missing? Just so you know my set up...if it makes any diffrence I am using WebMatrix 2 installed umbraco using the web-platform installer.

    I have one document type and one template with no children...I am writing the Razor directly in to this template.

    Thanks in Advance

    Ayo

     

     

     

  • Kevin Jump 2317 posts 14746 karma points MVP 7x c-trib
    Apr 15, 2013 @ 04:23
    Kevin Jump
    1

    hi

    i think you are mixing traditional web forms and MVC syntax. 

    You can run razor inline in web forms you just need to enclose it in a macro tag 

    <umbraco:Macro runat="server" language="cshtml">
    @{
    @Model.subTitle
    }
    </umbraco:Macro>

    using @Umbraco.Field("subTitle") is the Mvc Syntax,

    You can switch to Mvc by changing the defaultRenderingEngine setting in umbracosettings.config (in the config folder) - then create your template and it will be created as a MVC template. 

     

     

Please Sign in or register to post replies

Write your reply to:

Draft