Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I localized an ASP.Net web application with resx files in App_GlobalResources and it worked quite well. I could get resources from code behind and from markup with explicit (like this : <%$ Resources:Resource1, MyString1 %>)

Now, I am trying to embed resources into satellite assemblies. For each resource file, I set Embedded Resource in visual studio IDE, it works well in the code behind but I can't figure out how to get the resources from satellite assemblies from within the markup.

I googled this and I found only web sites talking about resources called from satellite assemblies from within code behind.

Is there a way to get resources from markup with satellite assemblies?

Thanks for your help
Posted
Updated 8-May-11 3:58am
v2

1 solution

Have you marked the resx's default Access Modifier to public? It defaults to Internal.

Take a squizz at this[^] and seach for "Now set the access modifier to public" the rest of the article is irrelevant.
 
Share this answer
 
v2
Comments
Christophe_ 9-May-11 14:41pm    
Thanks for your answer.

Yes, the modifier was already set to public. Following the page sample you provided me, I was able to localize a value in the markup but this only worked outside of asp.net controls.

An example will be clearer I think ;). Assuming I have a localized string MarkupText in a resource file Resource2 :

<div>

<!--this one worked-->
<%= Resources.Resource2.MarkupText %>

<!-- this one doesn't work -->
<asp:Label runat="server" ID="label1" Text="<%=Resources.Resource2.MarkupText%>"/>

<!-- this one doesn't work with satellite assemblies but worked with standard resx -->
<asp:Label runat="server" ID="label2" Text="<%$Resources:Resource2,MarkupText%>"/>

</div>


Why can't I use <%$... %> notation like in resx version ?
Keith Barrow 9-May-11 15:55pm    
Try Changing the first one to Text="<%= Resources....." note the extra space, I've found it a bit finnicky. The second one has a "," instead of "." after Resource2, please check this isn't a typo.
Christophe_ 11-May-11 3:22am    
I tried
<asp:TextBox runat="server" ID="textbox1" Text="<%= WebApplication.Resource2.Markup1 %>" />

<asp:TextBox runat="server" ID="textbox2" Text="<%= Resource2.Markup1 %>" />

<asp:TextBox runat="server" ID="textbox3" Text="<%$ Resources:Resource2.Markup1 %>" />

<asp:TextBox runat="server" ID="textbox4" Text="<%$ Resources:Resource2, Markup1 %>" />

<asp:TextBox runat="server" ID="textbox5" Text="<%$ Resources:WebApplication.Resource2, Markup1 %>" />

<asp:TextBox runat="server" ID="textbox6" Text="<%$ Resources:WebApplication.Resource2.Markup1 %>" />

None of them worked.

PS : Here is a link to VS2010 solution if anyone sees what I am doing wrong
VS2010 Solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900