Programmatically Setting Region and Locale

ASP.NET enables you to use the CultureInfo class at the page level to supply localized settings. Culture settings tell the application in what language it should display its content. In the case of a German traveler in the United States, this class would reflect the origin of the user—Germany.

The following example shows the initial culture setting to be the culture of the server:

culture = CultureInfo.CurrentCulture 

To use a different culture, use the following syntax:

culture = New CultureInfo(NewCulture.Value) 

The new culture now becomes the default setting. You can now show the page content in the new culture:

 <% Thread.CurrentThread.CurrentCulture = culture %> ... Current Culture is <%= CultureInfo.CurrentCulture.Name ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.