You can make a folder and put a class file in it. In this class file declare your variables. You can access these in any view. So, for example, I made a folder called NewFolder1. In that folder I put a class file called Class1.cs. In that file I put
this:
public class Class1
{
public static readonly string testing = "testing";
}
In my view I put this (Administration is my project name):
@Administration.NewFolder1.Class1.testing
This worked. Does this meet your requirement? You can let your localization team add variables to the Class1.cs file and then add those changes into your main project and compile it?
Reporting by definition is different. Otherwise we would just show it on the screen.
ryanbesko
Contributor
3561 Points
619 Posts
MVC4 - is it step backwards in relation to MVC3 when declaring and using global variables?
Dec 27, 2012 04:04 PM|LINK
You can declare them in the global.asax file.
public class MvcApplication : HttpApplication
{
public static string MyGlobalVariable = "somevalue";
...
}
Then you can access them in view like this (my project is called Administration):
@Administrationn.MvcApplication.MyGlobalVariable
Or in classes like this:
MvcApplication.MyGlobalVariable
Partyz
0 Points
2 Posts
Re: MVC4 - is it step backwards in relation to MVC3 when declaring and using global variables?
Dec 27, 2012 08:53 PM|LINK
Thank You!
ryanbesko
Contributor
3561 Points
619 Posts
Re: MVC4 - is it step backwards in relation to MVC3 when declaring and using global variables?
Dec 28, 2012 01:40 PM|LINK
You can make a folder and put a class file in it. In this class file declare your variables. You can access these in any view. So, for example, I made a folder called NewFolder1. In that folder I put a class file called Class1.cs. In that file I put this:
public class Class1 { public static readonly string testing = "testing"; }In my view I put this (Administration is my project name):
This worked. Does this meet your requirement? You can let your localization team add variables to the Class1.cs file and then add those changes into your main project and compile it?
Partyz
0 Points
2 Posts
Re: MVC4 - is it step backwards in relation to MVC3 when declaring and using global variables?
Dec 28, 2012 05:53 PM|LINK
Thank You!