Actually this is a double question,


I'm trying to get the right variation from the following code:

SPUtility.GetLocalizedString("$Resources:MyDefaultResourceFileName,MyWantedValueKey", "MyDefaultResourceFileName", SpContext.CurrentWeb.Language)

like that I'm always getting the value from the default resource file, but if I change the language on the SPWeb, for instance en-en, I'm not getting the key value from the MyDefaultResourceFileName.en-en.resx

solution: follow this link and use this code for retrieve the values from right resource file:

SPUtility.GetLocalizedString("$Resources:MyWantedValueKey", "MyDefaultResourceFileName", (uint)Thread.CurrentThread.CurrentUICulture.LCID)

but if is deployed as AppGlobalResource, check this link and use:

HttpContext.GetGlobalResourceObject("MyResourceFile", "MyKey")


And the second one more simple, how I get those same values in .aspx files?

solution: helpful link




SpContext.CurrentWeb.Language always returns languages that is used for site creation, if you would like to change languages on your site dynamically you should use `Thread.CurrentCulture.LCID'.

If you would like to get this values in .aspx file, you should create module that deploys resources files to the GlobalResources folder. See this post how to do it.

Then in you markup you can use <%$Resources:FileName,Key%> in server tag controls.

  • Thanks for the reply! very useful. After follow the link steps, the code is working just fine but actually is, Thread.CurrentThread.CurrentUICulture.LCID and the markup code is not working... – fallout Apr 2 '12 at 8:47
  • If you use <%$Resources:FileName,Key%> in server tag, you do not need to worry about Thread.CurrentThread.CurrentUICulture.LCID. The language is resolved by the system. – Alexander Apr 2 '12 at 10:05
  • are you sure alex? cause is not working with me...with <%$Resources:FileName,Key%> the value show is not from Thread.CurrentThread.CurrentUICulture.LCID lang. resource but the SPContext.Current.Web.Language – fallout Apr 2 '12 at 11:58
  • I'm sure. ) see this post. – Alexander Apr 2 '12 at 12:02
  • of course u r right!! my fault...some conflicts with code behind. I'll follow only the markup approach. many thanks alex! – fallout Apr 2 '12 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.