Last post Aug 30, 2006 09:26 PM by netNewBee
Aug 18, 2006 03:03 PM|netNewBee|LINK
Aug 21, 2006 01:44 AM|Gordon-Freeman|LINK
Hi~ You can use ResourceManager, the 1.1 way. For example:
System.Resources.ResourceManager rm = new System.Resources.ResourceManager("MyResource", System.Reflection.Assembly.GetExecutingAssembly());
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
Aug 22, 2006 11:02 AM|Serioga|LINK
Aug 23, 2006 04:17 PM|netNewBee|LINK
Aug 25, 2006 03:11 PM|netNewBee|LINK
I tried using this in my default.aspx and it works fine but does not work on my other file named default2.aspx.
this.Label1.Text =(string) HttpContext.GetGlobalResourceObject("ResourceDefault", "Label1")
The default2.aspx file always fallsback to use ResourceDefault.resx.
My App_GlobalResources has the following structure:
Can anyone tell me how to fix this problem?
Aug 26, 2006 01:35 AM|Gordon-Freeman|LINK
Hi~ You don't need to put resx files in different folder, just all in the App_GlobalResources.
Aug 28, 2006 02:26 PM|netNewBee|LINK
Thanks for your advice. I moved all the resouce files to the root folder and I still have the same problem.
Default.aspx works fine but not Default2.aspx (this file always reference ResourceDefault.resx)
I use the line below to referece the resouce files. Is this the correct way of referencing global resources files?
string test = (string)HttpContext.GetGlobalResourceObject("ResourceDefault", "Label1");
this.WelcomeLabel1.Text = test;
Aug 28, 2006 03:26 PM|Gordon-Freeman|LINK
Hi~ I'm not familiar with the GetGlobalResourceObject way, but now in 2.0 you may try the following:
Get your resx files ready in App_GlobalResources and compile the site, then you will get a namespace ::Resources, and Resources.ResourceDefault.Label1 is what you want (and it's strong typed)
Aug 30, 2006 04:22 PM|netNewBee|LINK
I finally figured it out. The web.config need this line under:
Aug 30, 2006 09:26 PM|netNewBee|LINK
It turned out that my web.config didn't have this line :
Now my resource files work in all the pages.