Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Expand]ASP.NET MVC Extensions
 [Collapse]Localization
   Localizing ASP.NET Controls via Satellite Resource Assemblies
   Localizing ASP.NET Controls via Localizer Objects
   How to: Set a Culture for an ASP.NET Web Page
   Localizing ASP.NET Controls via Global Resources (Obsolete from 11.2)
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Set a Culture for an ASP.NET Web Page

To localize a website, it must first be supplied with the required localization sources using the Satellite Resource Assemblies approach. The current site culture is defined by the Culture and UICulture properties, which can be specified in two different ways.

Expanded Localize a Website for a Specific Culture (regardless of operating system settings)

To localize a website for a certain culture, set the Culture and UICulture properties to the corresponding culture name. For a list of culture names, see the National Language Support (NLS) API Reference topic in MSDN. The properties can be set using the following approaches.

Declarative approaches

  • To set the culture for all pages, add a globalization element to the Web.config file, and then set the Culture and uiCulture attributes.

  • To set the culture for an individual page, set the Culture and UICulture attributes of the @ Page directive.

Programmatic approach

  • You can set the Culture and UICulture property values at runtime. For this purpose, override the InitializeCulture method where you must specify the Culture and UICulture properties. The programmatic approach can be useful if you need to change an application's language at runtime.

    Example

    This example demonstrates how to allow end users to change the site language at runtime. For this purpose, the InitializeCulture method is overridden to set the Culture and UICulture properties according to query values.

    The image below shows the result.

    Note

    To work properly, the project requires satellite resource assemblies.

Expanded Localize a Website for Numerous Cultures (based on the operating system settings)

This is the most common approach to localization. To apply it, provide multiple localization sources within your website for each culture to support. Then, set the Culture and UICulture properties to auto. After that, the program will automatically determine the operating system's culture info and load assemblies appropriate for this culture, so you do not have to write any code. You can set the Culture and UICulture property in any of the ways described above. For example:

End-users can manually set the culture in their browsers. For example, in Microsoft's Internet Explorer, users can click Tools | Internet Options. In the invoked dialog, they can select the General tab, click Languages, and then set their language preference.

Expanded See Also

How would you rate this topic?​​​​​​​