Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:31:40+00:00 2026-05-22T22:31:40+00:00

I am using Visual Studio 2008 and ASP.NET to build a web app. Most

  • 0

I am using Visual Studio 2008 and ASP.NET to build a web app. Most of my web pages are based on a single master page. This master page contains three button links that act as language switches; the Click event handlers look like this:

protected void lbuLangEN_Click(object sender, EventArgs e)
{
    this.SwitchLanguage(string.Empty);
}  

protected void lbuLangES_Click(object sender, EventArgs e)
{
    this.SwitchLanguage("es");
}

Then I have my private method SwitchLanguage:

private void SwitchLanguage(string culture)
{
    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
}

As far as I understand, this should be enough to make the pages based on my master page exhibit a localised behaviour, i.e. get their resources from the appropriate local resx file according to culture. However, it is not working. They always appear in Spanish, which is my browser’s default language. I have set some trace messages at the entry and exit points of SwitchLanguage, and apparently the current thread is not changing its culture info: every time SwitchLanguage is called, the current thread’s culture is “es-ES”, regardless of what my code has just set.

Is there any problem with my code or with the approach I am taking? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:31:40+00:00Added an answer on May 22, 2026 at 10:31 pm

    You could use OnAcquireRequestState in Global.asax to change the culture. It is called right after the session is loaded, but before any master page event.

    So in the button event handler, you set a session variable to the desired current culture. Then you redirect to the current page. The Global.asax event can then pick up the new language, right before the masterpage loads:

    protected void OnAcquireRequestState(object sender, EventArgs e)
    {
        string cultureName = "en-GB";
        if (HttpContext.Current.Session != null &&
            HttpContext.Current.Session["CultureName"] is string)
            cultureName = HttpContext.Current.Session["CultureName"];
    
        if (Thread.CurrentThread.CurrentUICulture.Name == cultureName) 
            return;
    
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
        Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
Applications I am using: Visual Studio 2008 (C#/ASP.NET) Visual Source Safe 8.0 IIS 5.1
If I'm using Visual Studio 2008 targeted to ASP.NET 2.0, then which version of
I am using Firefox 3 to debug my ASP.NET applications in Visual Studio 2008.
When I use Build->Publish Web Site in Visual Studio 2008, most of the time
While working with ASP.NET using Visual Studio (2008) I have discomfort issue: source code
Im creating a web application in asp.net visual studio 2008.. in my application, i
I'd like to import an ASP.NET MVC 2 app from Visual Studio 2008 to
I have developed a asp.net application using Visual Studio 2008 and it was working
So i am using visual studio 2008, asp.net 3.5, with the basic toolkit provided.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.