I believe this might be related to the UseUserOverride
property of the CultureInfo instances you create. (To set
the value of this property, use a CultureInfo ctor that
takes an optional bool parameter). The value of this
property determines whether you retrieve certain
formatting information from the user's settings as opposed
to the default for the culture.
So, I'd suggest trying to set UseUserOverride to false
when creating these CultureInfos. This should give more
reliable results.
[quoted text, click to view] >-----Original Message-----
>Hi all,
>
>I have a problem with an ASP.Net web app.
>
>As per all the suggestions for Globalisation I have seen
on the web
>and at TechEd, in my global.asax I obtain the user's
browser Locale
>settings and set the Culture for the thread accordingly:
>
>If Request.UserLanguages.Length > 0 Then
> culture = CultureInfo.CreateSpecificCulture
(Request.UserLanguages(0))
> Thread.CurrentThread.CurrentCulture = culture
>Else
> ' Explicitly set the culture to Aussie English
('cause it rocks!)
> Thread.CurrentThread.CurrentCulture =
>CultureInfo.CreateSpecificCulture("en-Au")
>End If
>
>I can see this working because I can emit the value of
the current
>culture to the screen and see the appropriate value ("en
au"). Also if
>I change my local settings to something else, Spanish for
example, I
>see the appropriate locale being picked up.
>
>The reason for doing this is to get any dates rendered
from the server
>in the user's local format. These works OK on most of the
machines I
>have tested it on. For example I set a text box date by:
>
>txtDate.Text = MeetingDate.ToShortDateString
>
>Where MeetingDate is a DateTime.
>
>This seems to work perfectly well in most places I have
tried it.
>Problem is, on one particular machine the dates always
display in US
>format, despite this machine having a Local of English
(Australia).
>Debugging the code and displaying in the result page
shows the locale
>being picked up correctly as "en au", but the date still
renders
>incorrectly.
>
>In desparation I set the Page locale specifically to en-
au as follows:
>
><%@ Page Language="vb" AutoEventWireup="false"
>Codebehind="Meeting.aspx.vb" Inherits="CR.Meeting"
culture="en-AU"%>
>
>And it works on the machine in question (dates in Aussie
format). I
>don't however want to set a specific culture so that the
app can be
>globalised.
>
>Has anyone come across such an issue before ?
>
>Cheers,
>
>Iain Carlin
>
>.