Last post Jan 27, 2009 05:17 PM by cgroneman
Jan 27, 2009 04:27 PM|cgroneman|LINK
I have been searching for a good way to access the resources in App_GlobalResources from within a compiled class library.
My application has several template variables stored in a database that get used often, from many pages. I currently have a user control with a function to replace the template variables with the correct localized text. However, I want to use codebehind
in my application, and from what I understand, I can't refer to user controls from codebehind files. That's why I'm trying to move this function to a compiled DLL. I want the DLL to use resx files from within the App_GlobalResources directory, because it's
a central place to manage the global strings, and I can easily add additional languages in the future, simply by dropping in a new resx file.
Ideally, I could simply call "Resources.file.resourcename" from within the Dll. Or, I could pass in the "file" class to my DLL to get the resource out of. I don't know how to do that. In playing with ResourceManagers, I can't figure out how to make
them work with the ASP.NET resources.
Do I need to write my own ResourceManager, using ResXResourceReaders? It seems to me that there must be an easier way. Is there?
Jan 27, 2009 05:17 PM|cgroneman|LINK
Ever ponder something for a few days, searching for a solution, post a question, and then find the solution immediately? Yeah. I feel dumb. The answer, for people who are searching and stumble upon this:
HttpContext.GetGlobalResourceObject(String, String, CultureInfo).
There's also one for LocalResources, if you're looking for that.