I'm really new to working with Razor, in fact this is my first attempt at using it. What I want to do is create a macro in which I can display bodyText from a node that I know the ID of. Here is what I have, I am creating a razor script in the scripts file.
var contentNode = new DynamicNode(1511); @contentNode.bodyText
Though this looks correct to me, when I try to save the script I get an error with the following details.
c:\Windows\Temp\aqpapjch.0.cs(22,7) : error CS0103: The name 'contentNode' does not exist in the current context
bodyText from node with ID
I'm really new to working with Razor, in fact this is my first attempt at using it. What I want to do is create a macro in which I can display bodyText from a node that I know the ID of. Here is what I have, I am creating a razor script in the scripts file.
var contentNode = new DynamicNode(1511);
@contentNode.bodyText
Though this looks correct to me, when I try to save the script I get an error with the following details.
c:\Windows\Temp\aqpapjch.0.cs(22,7) : error CS0103: The name 'contentNode' does not exist in the current context
What am I doing wrong?
Hi, the razor parser needs to have var declarations within @{} , you can simply choose to enclose the whole script within it like so:
is working on a reply...