469,097 Members | 1,240 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,097 developers. It's quick & easy.

CultureInfo getting hacked during page load.

OS: WIndows Server 2003.
Currently logged in user is running with German(German) regional settings.

Code fragment:
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("de-DE")
string name= culture.Name; // Produces "de-DE"
string s = (3.5).ToString(culture); // produces "3.5". Should produce "3,5"
string t = (new System.DateTime()).ToString("T",culture); // produces "2/16/2004". Should produce "16.2.2004"

If the currently logged in user is running with English(US) regional settings, the problem does not occur. This problem occurs for both locally and remotely connected HHTP settings.

What seems to be happening is that the regional settings for the CultureInfo corresponging to the default locale for the currently logged on user seems to get patched with en-US NumericFormat and DateFormat settings for the duration of OnInit and OnLoad. I can understand why somebody might want to do this. Problem is, that I have a validating date control that needs to convert posted values to native DateTimes. When I try to do

System.DateTime newDate =
System.DateTime.Parse(text)

in the postback handler, it failes, because it tries to parse the strings using the current CultureInfo, which has been mysteriously patched with en-US values. I'm helpless. There doesn't appear to be a way to get CultureInfo for "de-DE" that hasn't been hacked

If the logged in users' regional settings are changed to en-US (or, in fact, anything other the de-DE), everything works fine

Page generation works fine. By the time we get around to generating HTML, the correct format strings have been patched back in again

During postback handling, even

System.DateTime.Parse(text,new System.Globalalization.CultureInfo("de-DE"))

fails, because the Culture info returned includes the patches to the format patterns.

What's annoying is that I'm running with the right CultureInfo (Name="en-US") during page construction; and I even seem to be running with the right CultureInfo (Name="de-DE") during parameter postback.

Is there a way to disable this behaviour in ASP.NET?

I've tried explicitly setting the culture in the page. Doesn't help

Nov 18 '05 #1
1 1730
Hi,

I got the same problem with hebrew. changing the cultute attribute in
globalization tag at the web.config solved the problems for me.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by N | last post: by
2 posts views Thread by Duwayne | last post: by
1 post views Thread by John Cosmas | last post: by
2 posts views Thread by Boonaap | last post: by
2 posts views Thread by Chad | last post: by
4 posts views Thread by John A Grandy | last post: by
5 posts views Thread by Jason L James | last post: by
8 posts views Thread by Phil Jollans | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.