4

I created two files in the App_GlobalResources folder:

SiteResources.en-US.resx
SiteResources.sp-SP.resx

Both contain a value for "SiteTitleSeparator".

Here is what I am trying to do (The following line always returns null):

string sep = (string)GetGlobalResourceObject("SiteResources", "SiteTitle");

Note, that the Culture property on the page is set.

Answers in both VB and C# will be welcomed.

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
  • Note, that the Culture property on the page is set. ---------------------------------------------- How did you set the culture? I have Resources.resx and Resources.fr-CA.resx, but when I read the resources, it always return the value of the default Resources.resx... Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA"); labUsername.Text = GetGlobalResourceObject("Resource", "Username").ToString() + " : "; This code will not read Resources.fr-CA... Thank you – philberg Nov 06 '11 at 19:48
  • 1
    Hey philberg, I believe that for the .resx values to be used, you must set the CurrentUICulture, not the CurrentCulture. – Robba Jan 30 '13 at 14:37

2 Answers2

8

I changed the name of SiteResources.en-US.resx to SiteResources.resx and now everything works just fine.

Seems theer must be one invariant resource.

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
1

Yes: there has to be one .resx without a region code which will serve as a default.

simaglei
  • 1,118
  • 1
  • 14
  • 14