By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Regional Settings en-GB CultureInfo.CurrentCulture.Name = en-US

P: n/a
Hello,

I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?
Nov 18 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
What is the Windows regional setting for the user context in which the
server-side code is executing? I'm guessing that it's not the same account
under which you're viewing the regional settings since the latter is
probably the administrator account.
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
Hello,

I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?

Nov 18 '05 #2

P: n/a
On 8 Jul 2004 04:12:18 -0700, yu***@yahoo.co.uk (magister) wrote:
I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!


I'm not sure exactly what you want, but what we do (in Page_Load()) in
our ASP.Net applications - which I believe will give the effect you
want - is this call to a routine we wrote specifically to enable easy
multi-language/multi-date-format/etc:

UIUtilities.setCulture(Request);

Where this is what gets called:

/// <summary>
/// Set the display culture for the current thread to the most
appropriate culture from the user's incoming Http "request" object.
/// </summary>
/// <param name="request"></param>
internal static void setCulture(HttpRequest request)
{
if (request != null)
{
if (request.UserLanguages != null)
{
if (request.UserLanguages.Length > -1)
{
string cultureName =
request.UserLanguages[0];
UIUtilities.setCulture(cultureName);
}
}
// TODO: Set to a (system-wide, or possibly
user-specified) default culture if the browser didn't give us any
clues.
}
}

/// <summary>
/// Set the display culture for the current thread to a particular
named culture.
/// </summary>
/// <param name="cultureName">The name of the culture to be set for
the thread</param>
private static void setCulture(string cultureName)
{
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(cultureName);
Thread.CurrentThread.CurrentUICulture = new
CultureInfo(cultureName);
}
What this does is that the thread that processes the output (and
input) for that user for the page is AUTOMATICALLY set for the
appropriate culture (eg for date input/output) for that user. It uses
a header which is sent automatically by the browser (4.0 and later -
works fine with Firefox/Mozilla too), so the user of your ASP.Net
application doesn't have to separately select a language/culture
preference in the application.

NB: You can change this setting for testing (in IE for example) by
going to Tools/Internet Options/Languages, then adding the language
you want to test and moving it to be the first/top one.

Because it is per-user, rather than being based on a server setting,
it is a lot more flexible as far as being "world-ready".

FWIW we use the same browser header to work in with the
ResourceManager mechanism to provide other-language text in the output
web pages too, simply by doing the following after the call to set the
thread culture to the right one for the user:

ResourceManager resourceManager = new
ResourceManager("AppName.strings", typeof(SampleForm).Assembly);

(then using ctrl.Text = resourceManager.GetString("NameOfItem") as
normal)

The net effect of all this is that a user who wants dates the "right
way" around (I'm an Australian) for output and input validation will
have the page work that way, and someone who prefers MM/DD/YYYY will
in turn have that work for their input/output WITHOUT you having to do
anything hardwired in your code, or forcing users to select a
language/culture preference for your app in their logon details.

ted.h.
--
Ted Harper (Sydney, Australia)
Nov 18 '05 #3

P: n/a
Where can I check&change the regional settings of my user account?
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message news:<O7**************@TK2MSFTNGP09.phx.gbl>...
What is the Windows regional setting for the user context in which the
server-side code is executing? I'm guessing that it's not the same account
under which you're viewing the regional settings since the latter is
probably the administrator account.
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
Hello,

I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?

Nov 18 '05 #4

P: n/a
Depends which user account is being used. Unless you're impersonating a
custom user, chances are you'll need to manually edit the registry since you
probably won't be able to run the regional settings control panel for, say,
the ASPNET user unless you've been mucking with its password.

That said, I wouldn't recommend using this approach. It's a much better
idea to programmatically set the appropriate culture rather than relying on
the configuration of the web server or the runtime user context. Either of
these might be altered at any time to support some other application's
dependency. Also, you might find yourself needing to support the client
regional preferences, in which case programmatic setting is the only way to
go.

HTH,
Nicole
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
Where can I check&change the regional settings of my user account?
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:<O7**************@TK2MSFTNGP09.phx.gbl>...
What is the Windows regional setting for the user context in which the
server-side code is executing? I'm guessing that it's not the same
account
under which you're viewing the regional settings since the latter is
probably the administrator account.
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...
> Hello,
>
> I know I can set the Culture to what I want, but shouldn't the current
> culture be taken from the regional settings on the web server's
> control panel!!!
>
> Mine is set to "united kingdom"
>
> but in my asp.net page I do
>
> string cl = CultureInfo.CurrentUICulture.Name;
> string cn = CultureInfo.CurrentCulture.Name;
>
> both string return en-US
>
> I need this to be en-GB so my comparevalidator will do a date check on
> a textbox....
>
> Anyone else experience this?

Nov 18 '05 #5

P: n/a
On 9 Jul 2004 05:28:41 -0700, yu***@yahoo.co.uk (magister) wrote:
Where can I check&change the regional settings of my user account?


You (probably) don't want to change the regional settings of "your"
user account, or even the ASPNET account on the server, but rather you
want to change them on the _thread_ doing the work on the ASP.Net
server to the regional settings of the CALLING users.

I posted a larger code fragmenet for you to do this in my other post
in this thread (which may not have propagated to you yet), but here is
basically what you do in Page_Load():

string cultureName = request.UserLanguages[0];
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(cultureName);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);

Once you have done that (up the top of Page_Load(),
DateTime.ToString() and DateTime.Parse() will operate with respect of
the culture settings of each calling user.

This operates using a standard browser header that is sent by 4.0 and
later browsers and indicates the language/culture preference of the
user. You can change the settings your browser sends for testing
purposes via Tools/Internet Options/Languages - add the language you
want and move it to the top/first position, then refresh the page you
are testing against (assuming it has implemented the logic above in
its Page_Load()), and you'll see the input/output formats change
appropriately.
ted.h.
--
Ted Harper (Sydney, Australia)
Nov 18 '05 #6

P: n/a
bb
hello, im experiencing exatly the same problem, and suspect the answer
is something along the lines of what someone has linked to this message.

im now trying to find out how and where to set the locale settings for
whomever is owning the iis process (LocalSystem)

magister wrote:
Hello,

I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?

--
------------------------
Think your smart?
Prove your programming power @ the OSI Geek Challenges
http://www.osix.net
------------------------
Nov 18 '05 #7

P: n/a
bb
magister wrote:
Hello,

I know I can set the Culture to what I want, but shouldn't the current
culture be taken from the regional settings on the web server's
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?

Fixed this.

its something along the lines of this thread here ....
http://www.mcse.ms/message872783.html

i played around with what it suggested, but it didnt work, so instead, i
just looked through the HKEY_USERS registry entries looking at each's
control panel/international settings.

when i found one that had US rather than UK, i modified it, restarted
iis then requested my dummy page which outputs the locale.

eventually i found the right entry (which in my case was user S-1-5-20
which i guess corresponds with either the ASPNET user or the
IUSER_MACHINENAME account )

dont forget to restart iis after each change.


--
------------------------
Think your smart?
Prove your programming power @ the OSI Geek Challenges
http://www.osix.net
------------------------
Nov 18 '05 #8

P: n/a

Hi
Thank you for your site Resp.
And Happy New Year.
Bye
--
lindavids
------------------------------------------------------------------------
lindavids's Profile: http://www.hightechtalks.com/m517
View this thread: http://www.hightechtalks.com/t23260

Dec 30 '06 #9

P: n/a

Very Interesting
Thanks you for your work.
Best regards.
--
alexdixis
------------------------------------------------------------------------
alexdixis's Profile: http://www.hightechtalks.com/m520
View this thread: http://www.hightechtalks.com/t23260

Jan 1 '07 #10

P: n/a

Very Interesting
'stati uniti shopping'
(http://euro.initalyall.com/stati-uniti-shopping.html) stati uniti
shopping http://euro.initalyall.com/stati-uniti-shopping.html 'ricerca
domini' (http://euro.initalyall.com/ricerca-domini.html) ricerca domini
http://euro.initalyall.com/ricerca-domini.html

Best regards.
--
alinapush
------------------------------------------------------------------------
alinapush's Profile: http://www.hightechtalks.com/m521
View this thread: http://www.hightechtalks.com/t23260

Jan 2 '07 #11

P: n/a

Hi all!
The information is successfully classified. Reasonable structure of a
site.This is a great website! Real nice! Thanks much!
may be my site interesting for you ?
'fotocamera' (http://allitalysite.info/fotocamera.html) fotocamera

http://www.allitalysite.info
Bye
--
alenasverid
------------------------------------------------------------------------
alenasverid's Profile: http://www.hightechtalks.com/m530
View this thread: http://www.hightechtalks.com/t23260

Jan 5 '07 #12

P: n/a

Cool site. Thank you!!! legislation gambling internet Excellent design,
thanks for a site! You discuss very good subject. Very good web site,
great work and thank :) you for your service.
Maybe my site interesting to you <a
href=http://cas.romeupdate.info/portatile.html>portatile</a>
--
anukadevkizm
------------------------------------------------------------------------
anukadevkizm's Profile: http://www.hightechtalks.com/m535
View this thread: http://www.hightechtalks.com/t23260

Jan 5 '07 #13

This discussion thread is closed

Replies have been disabled for this discussion.