CurrentUICulture problems en-GB

  • Thread starter Thread starter Murray
  • Start date Start date
M

Murray

I have put the following code in two pages:

Thread.CurrentThread.CurrentUICulture=new CultureInfo("en-GB");
Response.Write(CultureInfo.CurrentUICulture.EnglishName);
Response.Write(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern);
Response.Write(DateTime.Now.ToShortDateString());

in one page I get:
English (United Kingdom)M/d/yyyy30/03/2004

in the other I get:
English (United Kingdom)M/d/yyyy3/30/2004

Exactly the same code in the Page_Load on the same machine!
Both have the same Culture settings in the web.config
A part from the ShortDatePattern being wrong for the en-GB...
What is going on here?
Thanks
Murray
 
There are 2 kinds of culture settings in .NET - CurrentCulture and
CurrentUICulture.
CurrentUICulture is used to get specific resources for a certain culture -
like strings for menu descriptions, etc, which you store in different
satellite resources.
CurrentCulture is for regional settings like dates, currency, number
formatting, etc. Thats the one you want here.

i.e.:
Thread.CurrentThread.CurrentCulture=new CultureInfo("en-GB");
Response.Write(CultureInfo.CurrentCulture.EnglishName);
Response.Write(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);

HTH,
Pete Beech
 
Hi, Murray,

It is the CurrentCulture property that is taken in consideration. Try
setting it instead.

Hope this helps
Martin
 
Back
Top