So what I am trying to do is getting the name of the settingsNode i declared in the Globalvariables.cshtml file. However I get an error when loading the page, that says the following:
Error loading Razor Script MetaTags.cshtml \macroScripts\MetaTags.cshtml(3): error CS0103: The name 'settingsNode' does not exist in the current context
Is ii possible to make the settingsNode exist in the context of the MetaTags file? I am newbie when it comes to Razor, so any help will be much appreciated :-)
Unfortunately, as far as I have been able to find out, RenderPage just produces the output of a .cshtml script. It does not offer access to variables declared in it.
The cool thing is that you can do something like
string name = RenderPage("GetName.cshtml")
to place whatever output derives from GetName.cshtml in the "name" variable.
There are some ways to reuse data produced or retrieved in a script from another script, which have been discussed here:
RenderPage question
Hi, I just started playing around with Razor and I ran into a little problem.
I have a razor macro called MetaTags with an assosiated razor file (MetaTags.cshtml), the file looks like this:
As you can see, the first thing I do is render another razor file (GlobalVariables.cshtml) which looks like this:
So what I am trying to do is getting the name of the settingsNode i declared in the Globalvariables.cshtml file. However I get an error when loading the page, that says the following:
\macroScripts\MetaTags.cshtml(3): error CS0103: The name 'settingsNode' does not exist in the current context
Is ii possible to make the settingsNode exist in the context of the MetaTags file?
I am newbie when it comes to Razor, so any help will be much appreciated :-)
/Thor
Hi Thor,
Unfortunately, as far as I have been able to find out, RenderPage just produces the output of a .cshtml script. It does not offer access to variables declared in it.
The cool thing is that you can do something like
string name = RenderPage("GetName.cshtml")
to place whatever output derives from GetName.cshtml in the "name" variable.
There are some ways to reuse data produced or retrieved in a script from another script, which have been discussed here:
http://our.umbraco.org/forum/developers/razor/20700-Including-and-sharing-variable-throug-Razor-files
I hope that this helps!
Dimitri
Hi Dimitri,
Thanks alot, that pointed me in the right direction :-)
/Thor
is working on a reply...