Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:
dynamic settingsNode = new DynamicNode(1049);
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:
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:
I hope that this helps!
Thanks alot, that pointed me in the right direction :-)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted