Configuring Template to Render Property Using Razor
Hello - basic question here, looking for best practice suggestions.
I have a standard TextPage with a "bodyText" property. What is the recommended way to write the Razor code in my template so it renders the text entered into bodyText box?
I got it to work by inserting a page field:
@Umbraco.Field("bodyText")
But as I'm doing some reading it seems that is the wrong way to go about it and I should be inserting this script:
@Model.bodyText
But the above does not render my bodyText property and I get a compilation error:
'Umbraco.Web.Models.RenderModel' does not contain a definition for 'bodyText' and no extension method 'bodyText' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
Configuring Template to Render Property Using Razor
Hello - basic question here, looking for best practice suggestions.
I have a standard TextPage with a "bodyText" property. What is the recommended way to write the Razor code in my template so it renders the text entered into bodyText box?
I got it to work by inserting a page field:
@Umbraco.Field("bodyText")
But as I'm doing some reading it seems that is the wrong way to go about it and I should be inserting this script:
@Model.bodyText
But the above does not render my bodyText property and I get a compilation error:
Thanks in advance!
You could do this:
More info here:
http://our.umbraco.org/documentation/Reference/Mvc/views
http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Jeroen
Cheers for the examples and links Jeroen!
is working on a reply...