Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I have a huge project to work on in various different languages. So we have decided to use resource.resx files for this purpose.

I understand that buttons, labels, and other properties can easily obtain the correct value from the resource file by selecting the correct CultureID. But at the same time I have several other content (not labels or buttons) that could benefit from a resource file for translation. That is content in header tags <h> or Div tags <div> or even complete tables with information within their cells.

Is there a way that a block of code (example a whole static table) can be retrieved from a Resource.resx file and be referenced (that is: used) directly in the .aspx file, (not code behind) without being a text property of a button or label?

Thanks for your help.
Posted

Yes you can do this. You can use the literal control like this:
<asp:Literal ID="foo" runat="server" Mode="Transform" Text="<h1>Hello</h1>" />

and you'll get a correctly rendered h1 element. All you need to do is set the Text property from your resx file as you would for any other control. One further thing is you might need to set the Mode to PassThrough, it depends what you are doing.
 
Share this answer
 
Keith,

Thanks for your solution, it works. After further research I also noticed you can store information in the resource file and later access it using the <%= %> and the GetGlobalResourceObject Example:

<%= GetGlobalResourceObject ("Resource", "Field") %>

That way even without using asp:Literal whatever you store in the resource file would be retrieved and displayed.

Just a bit more of information to that matter.

Thanks,

Ricardo
 
Share this answer
 
v2

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