I have a site with login page.
In that page i placed a dropdownlist that have 3 language
I can change the second and third language in the dropdownlist but not the first
I use cookie so in the login.aspx and basePage(inherit from System.Web.UI.Page)
<asp:DropDownList ID="ddlLanguages"
runat="server"
AutoPostBack="true"
OnSelectedIndexChanged="ddlLanguages_SelectedIndexChanged">
<asp:ListItem Text="Ita" Value="it-IT" />
<asp:ListItem Text="Eng" Value="en-US" />
<asp:ListItem Text="Esp" Value="es-AR" />
</asp:DropDownList>
protected void ddlLanguages_SelectedIndexChanged(object sender, EventArgs e)
{
HttpCookie language = new HttpCookie("UserLanguage");
switch (ddlLanguages.SelectedItem.ToString())
{
case "Ita":
language.Values["UserLanguage"] = "it-IT";
break;
case "Eng":
language.Values["UserLanguage"] = "en-US";
break;
case "Esp":
language.Values["UserLanguage"] = "es-AR";
break;
default:
break;
}
language.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(language);
}
In the BasePage (BasePage : System.Web.UI.Page):
protected override void InitializeCulture()
{
String userLang = "";
if (Request.Cookies["UserLanguage"] != null)
{
HttpCookie CookieKey = Request.Cookies["UserLanguage"];
String cookieValue = CookieKey.Value.Split('=')[1];
switch (cookieValue)
{
case ("it-IT"):
userLang = cookieValue;
break;
case ("en-US"):
userLang = cookieValue;
break;
case ("es-AR"):
userLang = cookieValue;
break;
}
Thread.CurrentThread.CurrentCulture = new CultureInfo(userLang);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(userLang);
}
else
{
userLang = "it-IT";
Thread.CurrentThread.CurrentCulture = new CultureInfo(userLang);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(userLang);
}
}
I can set Es and then En but not Es (or En) and then It . Why ?