473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Culture. What am I doing wrong?

Hello,

I am initializing the culture of a page as follows:

protected override void InitializeCulture() {
base.InitializeCulture();
CultureInfo culture = Profile.Get().Visitor.Culture;
if (culture == null) culture = default(CultureInfo);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}

Basically, my objective is to get the culture from Visitor property in
profile. If it is null then use the default culture in Web.Config:

<globalization
culture="auto:pt-PT"
uiCulture="auto:pt-PT"/>

The problem is that when the culture is null in profile I always get
"en-US".

What am I doing wrong?

Thanks,

Miguel
Oct 9 '08 #1
1 1527
Hi Miguel,

Your problem is default( CultureInfo ) which gives null. You should use new
CultureInfo("pt-PT"); or better yet:

culture = CultureInfo.CurrentCulture;

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com/weblog


"shapper" <md*****@gmail.comwrote in message
news:a3**********************************@v28g2000 hsv.googlegroups.com...
Hello,

I am initializing the culture of a page as follows:

protected override void InitializeCulture() {
base.InitializeCulture();
CultureInfo culture = Profile.Get().Visitor.Culture;
if (culture == null) culture = default(CultureInfo);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}

Basically, my objective is to get the culture from Visitor property in
profile. If it is null then use the default culture in Web.Config:

<globalization
culture="auto:pt-PT"
uiCulture="auto:pt-PT"/>

The problem is that when the culture is null in profile I always get
"en-US".

What am I doing wrong?

Thanks,

Miguel
Oct 10 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bruce_taylor | last post by:
Please forgive me if this is a little off topic, but I'm trying to reach a population of active programmers and this newsgroup is an popular gathering place. I am conducting research on the...
1
by: Dejan Vesic | last post by:
I found nasty "documentation" bug; ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemglobalizationcultureinfoclasstopic.htm claims that proper culture info name for Serbian (Cyrillic) - Serbia...
2
by: Aliasgar Pocketwala | last post by:
Hi, I have an asp.net application that is using the wrong culture. I cant figure out where does it get its setting from. My web application runs as a specific user since so that I can give it...
1
by: Chris Porter | last post by:
Just as I thought I was understanding doing timezone offsets I ran the following code : CultureInfo en = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentCulture = en;...
3
by: Ian O'Rourke | last post by:
Okay, I have a problem with the en-GB culture object My computer is set to the UK and for UK date formats, etc If I set my culture to en-GB in the web.config everything works fine with UK dates...
2
by: Hardy Wang | last post by:
Hi, We migrated some of web applications to a new server. When the server was installed, the regional setting was EN-CA, later on we found culture display was not same as from original server...
4
by: Henke | last post by:
Hi I'm building an globalized application (english, swedish and russian languages) and have a few questions: 1. In order to see the russian characters correct I have to set the requestEncoding...
2
by: jeffmagill | last post by:
Hi everyone! As the title says, I'm to access the default culture for the browser at run time. Furthermore as some side notes, my application's goal is to accomplish this at the application...
12
by: lucky | last post by:
hi guys, right now i'm going through System.Globalization Namespace. and i found very intersting class there called CultureInfo. i was trying to get cultureInfo on the basis of name but i didnt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.