views:

406

answers:

1

I have an asp.net app with some local resources. These resources are used in the aspx and code-behind files:

aspx:
<asp:TextBox ID="TextBox1" runat="server" Text="<%$ Resources:testTag %>" />

.vb:
TextBox1.Text = GetLocalResourceObject("testTag").ToString

If I deploy the .resx files with the app, there are no problems.

However, if I change the build action on the resx file to "Embedded Resource", the resources aren't available, even though they're in the DLL that gets built.

Is it possible to deploy resources in a DLL, or am I stuck with managing & deploying resx files on the server?

A: 

Yes, it's possible.

Check out this codeproject example. It's a little old, but still valid.

Another example, from microsoft, is here.

UPDATE

To be honest, I haven't gone this far with our own localizations yet (we still use the normally embedded resource files); however, here is a link to an example on how to get the resource manager accesible from your aspx page. It's the last post in that thread.

GeorgeZ states to load the Resource Manager in the page_init method. I'm sure you could put that into some type of BasePage that all of your pages inherit from in order to keep from having it directly in all of their code behinds.

Chris Lively
There doesn't seem to be a way to handle the localized strings in the aspx page using this mechanism. We have a ton of labels that are never touched in the code-behind, but that still need to display localized values.
chris