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 4067292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:13:52+00:00 2026-05-20T16:13:52+00:00

My page won’t change the language could someone have a look at my code

  • 0

My page won’t change the language could someone have a look at my code and tell me what im doing wrong it always goes to the default language

public partial class ChangeLanguage : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary<string, string> objDic = new SortedDictionary<string, string>();

        foreach (CultureInfo ObjectCultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
        {
            RegionInfo objRegionInfo = new RegionInfo(ObjectCultureInfo.Name);
            if (!objDic.ContainsKey(objRegionInfo.EnglishName))
            {
                objDic.Add(objRegionInfo.EnglishName, ObjectCultureInfo.Name);
            }
        }

        foreach (KeyValuePair<string, string> val in objDic)
        {
            ddlCountries.Items.Add(new ListItem(val.Key, val.Value));
        }

        ddlCountries.SelectedValue = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
    }

    protected void btnChangeLanguage_Click(object sender, EventArgs e)
    {
        ProfileCommon profile = HttpContext.Current.Profile as ProfileCommon;
        profile.Preferences.Culture = ddlCountries.SelectedValue;
    }
}
protected override void InitializeCulture()
  {
     string culture = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
     this.Culture = culture;
     this.UICulture = culture;
  }
Profile:
  <properties>
    <add name="FirstName" type="String"/>
    <add name="LastName" type="String"/>
    <add name="Gender" type="String"/>
    <add name="BirthDate" type="DateTime"/>
    <add name="Occupation" type="String"/>
    <add name="WebSite" type="String"/>
    <group name="Preferences">
      <add name="Culture" type="String" defaultValue="en-NZ" allowAnonymous="true"/>
    </group>
  </properties>
  • 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-20T16:13:52+00:00Added an answer on May 20, 2026 at 4:13 pm

    Several problems here, but the main one is that you in Page_Load do:

    ddlCountries.SelectedValue = (HttpContext.Current.Profile as ProfileCommon
    

    Then in the eventhandler for the click event do:

    profile.Preferences.Culture = ddlCountries.SelectedValue;
    

    Unfortunately for you, the Page_Load event fires before your click event, and since the Page_Load event sets the selectedvalue of the dropdownlist to the value already stored in the Profile object, and you then save the selectedvalue of the dropdownlist (which is no longer what you selected prior to clicking your button) you essentially just ignore the selected value and continue to use the default (or former) value.

    Move the code that selects the value in the dropdownlist to Page_PreRender (remove it from Page_Load), and you will be fine (example):

        protected void Page_PreRender(object sender, EventArgs e)
    {
        string culture = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
        if (ddlCountries.Items.FindByValue(culture) != null)
        {
            ddlCountries.SelectedValue = (HttpContext.Current.Profile as ProfileCommon).Preferences.Culture;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site in development here: http://63.144.105.101/perfect-card-creator-step-3 (This page won't display everything unless
I've come across a bug in my site: basically, it won't allow page names
The following script will update the database, but it won't display the correct page
When using Cache-Control and Expires header so that a page won't expire in 10
I have a html page with multiple similar elements which can be edited in-place:
For some reason this page won't work in Opera + Safari http://dev.reggi.com/clients/mike2/ this is
This query runs when I comment out the code above '}else{'. Have done so
I'm using Akismet for my spam protection on my web page. It won't even
Consider a part of a web page: <script> function fun() { alert(Link won't work);
Just starting out in asp.net. Have just created a login.aspx page in my site

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.