[ad_1]
I am interested in using only Global resource files in the “App_GlobalResources” folder and not having separate files in the “App_LocalResources” for web form labels.
I like the idea of centralizing all the resource strings in one place.
My resx files in App_GlobalResources have the following properties:
Build Action: Embedded Resource
Copy to Output Directory: Do not copy
Custom Tool: PublicResXFileCodeGenerator
Custom Tool Namespace: Resources
This works fine when calling a variable in markup such as:
<p><%=MyStrings.This_is_a_test_string%></p>
It also works fine in the code behind:
Dim strTest As String = MyStrings.This_is_a_test_string
The problem occurs when I attempt to bind a global resource string to a web form control such as:
<asp:Label ID="lblFullName" runat="server" Text="<%$ Resources:MyStrings, This_is_a_test_string %>" AssociatedControlID="txtFullName"></asp:Label>
The web server displays this error:
The resource object with key 'This_is_a_test_string' was not found.
I did notice if I change “Build Action” to “Content” that the resx will correctly bind to the Label control.
However, the problem is the strings will no longer work in the markup or the codebehind any longer.
So, is there a way to use ONE global resource file for the markup, codebehind, and for web form Label controls?
Or, am I forced to use two separate resource files?
At this point I’ll admit that I’m thoroughly confused.
[ad_2]