If you need to share resources across multiple pages you can use global resources as opposed to the local resources shown in the previous blog. Global resources are implemented using explicit binding, i.e. server tags like this one:
<%$ Resources:MyGlobalResources, OrderButtonText %>
The syntax is <% Resources:Class, ResourceID %> where Class is the name of the resource file, but without the culture and "resx" extensions. ResourceID is the name of the entry in the resource file.
By the way, you can use explicit syntax for local resources, but must use explicit syntax for global resources.
The basic steps for global resources to work are:
Try this step-by-step in an example with a RadioButtonList of drinks and an Order button.
<div> <asp:RadioButtonList ID="rblDrinks" runat="server" Width="262px"> <asp:ListItem Selected="True" Text="<%$ Resources:MyGlobalResources, CoffeeText %>"></asp:ListItem> <asp:ListItem Text="<%$ Resources:MyGlobalResources, OrangeJuiceText %>"></asp:ListItem> <asp:ListItem Text="<%$ Resources:MyGlobalResources, MangoJuiceText %>"></asp:ListItem> <asp:ListItem Text="<%$ Resources:MyGlobalResources, BottledWaterText %>"></asp:ListItem> </asp:RadioButtonList> <asp:Button ID="btnOrder" runat="server" Text="<%$ Resources:MyGlobalResources, OrderButtonText %>" Width="113px" /> </div>
Global resources let you organize your resource files however you like and let you re-use the material anywhere in the project. Global and local resources are both codeless and relatively painless methods you can use to localize your site.
Remember Me
a@href@title, i, strike, u
Copyright © 2003-2008 Falafel Software Inc.
Subscribe to Falafel Blogs
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!