Click here to Skip to main content
11,705,610 members (48,376 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET localization
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 7-May-11 23:59pm
Edited 8-May-11 3:58am
thatraja246.4K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
Christophe_ at 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 at 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_ at 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)

  Print Answers RSS
0 OriginalGriff 229
1 Sergey Alexandrovich Kryukov 100
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 8 May 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100