Global Resources


The previous example used a resource called WarningColor. This resource was local to the page, but in all probability, the same resource should be available throughout the application. For this reason, ASP.NET supports global resources. Global resources are available globally throughout an ASP.NET application. To change the previous example to use a global WarningColor resource, start by adding an App_GlobalResources folder. In Solution Explorer, right-click the Web site, and select Add, Add ASP.NET Folder, App_GlobalResources. Add a new resource file to this new folder and call the resource file GlobalColors.resx. Add a new entry for WarningColor with a value of Red. Select the button and open the Expressions property from the Properties Window. Change the ClassKey to GlobalColors (see Figure 5.10).

Figure 5.10. Assigning a Global Explicit Expression to a Property


The button's BackColor property is changed to this:

 BackColor="<%$ Resources:GlobalColors, WarningColor %>" 





.NET Internationalization(c) The Developer's Guide to Building Global Windows and Web Applications
.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
ISBN: 0321341384
EAN: 2147483647
Year: 2006
Pages: 213

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net