CurrentUICulture problems en-GB

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
 
P

Pete Beech

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
 
M

Martin Dechev

Hi, Murray,

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

Hope this helps
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top