471,893 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

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 1822
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.