views:

27

answers:

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>