O'Reilly logo

ASP.NET 2.0 Cookbook, 2nd Edition by Geoffrey T. LeBlond, Michael A Kittel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.3. Using Global Resources and Overriding Currency Formatting

Problem

You want to reuse resources throughout your international application, and you must always display currency with the U.S. dollar symbol, but all other text must follow the language setting in the browser.

Solution

Create a root global resource for your application, add the required items, explicitly set the values of static text in the .aspx files, set the culture and uiCulture attributes of the <globalization> element in web.config to auto, and set the values for dynamic controls in the code-behind class overriding the UI Culture when setting currency values.

Create a global resource file as follows:

  • Create an App_GlobalResources folder in the root of your application.

  • Add a resource file to the App_GlobalResources folder.

  • Edit the resource file to include the required items.

  • Duplicate the root resource file for each language and culture to be supported by your application, setting the values to the resource items as appropriate for the language.

In the .aspx files of your application:

  • Explicitly set the values for all controls that display static text.

Set the culture and uiCulture attributes of the <globalization> element in web.config to auto;

	<globalization culture="auto" uiCulture="auto" />

In the code-behind class for each page that needs to support multiple languages, use the .NET language of your choice to:

  • Set the values of controls used for date.

  • Set the values of controls used for currency overriding the UI Culture ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required