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 %>    (<%=Thread.CurrentThread.CurrentCulture.Name%>),    <%= CultureInfo.CurrentCulture.EnglishName %>/<%= CultureInfo.CurrentCulture.NativeName% graphics/ccc.gif >,    The localized date is: <%= DateTime.Now.Format("D", CultureInfo.CurrentCulture) %> 

ASP.NET allows the use of the RegionInfo class as well. It is much like the culture class. With RegionInfo , in the case of a German traveler in the United States, this class would reflect the location of the user ”the United States.

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

 region = RegionInfo.CurrentRegion 

To use a different region, use the following syntax:

 region = New RegionInfo(NewRegion.Value) 
   


Special Edition Using ASP. NET
Special Edition Using ASP.Net
ISBN: 0789725606
EAN: 2147483647
Year: 2002
Pages: 233

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