Culture and UI Culture for ASP.NET Web Page Globalization  

Posted by: Quadtechindia in

In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.
The two culture settings do not have to have the same value. Depending on your application, it might be important to set them separately. An example is a Web auction site. The UICulture property might change for each Web browser, whereas the Culture stays constant. Therefore, prices are always displayed in the same currency and formatting.

<%@ Page Language="C#" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
script runat="server"
protected override void InitializeCulture()
if (Request.Form["ListBox1"] != null)
String selectedLanguage = Request.Form["ListBox1"];
UICulture = selectedLanguage ;
Culture = selectedLanguage ;

Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture = new
form id="form1" runat="server"
asp:ListBox ID="ListBox1" runat="server"
asp:ListItem Value="en-US"
Selected="True"English /asp:ListItem
asp:ListItem Value="es-MX">EspaƱol /asp:ListItem
asp:ListItem Value="de-DE">Deutsch /asp:ListItem
br /
asp:Button ID="Button1" runat="server"
Text="Set Language"
meta:resourcekey="Button1" /
br /
asp:Label ID="Label1" runat="server"
meta:resourcekey="Label1" /

tags cannot be posted so please add angels brackets

This entry was posted on Wednesday, November 04, 2009 and is filed under . You can leave a response and follow any responses to this entry through the Subscribe to: Post Comments (Atom) .


Post a Comment