tags:

views:

638

answers:

4

Hello!

I'm developing an app with ASP.NET 3.5 and I have read that the language that the application is shown is the navigator's language.

Is there any way to choose the language of the application programatically? For example, I want to see the application in english but my Internet Explorer is in Spanish.

The language is a user's preference stored in database, so I need to change the language when the user do login.

Thank you!

+3  A: 

You can use the CultureInfo class to set the culture for your executing environment.

CultureInfo ci = new CultureInfo("en-US", false);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
Kirtan
Only you have understand my question!!!
VansFannel
A: 

Are you asking how to change your browser's accept language? See http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx for instructions for IE 7 and IE 8. The section you want is "To add a language to Internet Explorer"

Matthew Flaschen
No, I asking how to change programmatically the languague of my application.
VansFannel
You could have explained it more clearly. Specifically mentioning Internet Explorer and its current language settings obviously makes people think your question is related to...Internet Explorer. Hopefully, Kirtan's answer helps you.
Matthew Flaschen
A: 

You can also set it in web.config:

<configuration>
 <system.web>
  <globalization
    requestencoding="utf-8"
    responseencoding=" utf-8"
    fileencoding=" utf-8"
    culture="en-US"
    uiculture="en-US" />
 </system.web>
</configuration>

Or at the page level:

<%@ Page Culture="en-US" UICulture="en-US" ResponseEncoding="utf-8"%>
fretje
The language is a user's preference. I have to take this preference from SQL Server and then change the application's language.
VansFannel
Okay, then you have to do it like Kirtan suggests... I only added this for completeness ;-)
fretje
A: 

You can use this <globalization culture="en-US" uiCulture="en-US"/> in <system.web> section of web.config.

iburlakov