This is my code, the main problem is when I select the language I want to, it changes to the language, but if I click to another web page it turns to the original one. Example: I select english, then it changes all the page to english but if I click to another link in the page, the language changes to the default language.
here is the code. Hope someone can help me.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Globalization;
using System.Resources;
namespace Jaltepec
{
public partial class MainMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cargaComboLenguajes();
}
}
private void cargaComboLenguajes()
{
String lenguage = Request.QueryString["lenguaje"] == null ? "" : Request.QueryString["lenguaje"];
if (lenguage == "en")
{
cmbIdioma.SelectedValue = "en-us";
}
else
{
cmbIdioma.SelectedValue = "es-mx";
}
}
protected void cmbIdioma_SelectedIndexChanged(object sender, EventArgs e)
{
string language = cmbIdioma.SelectedValue;
if (!string.IsNullOrEmpty(language))
{
if (language.EndsWith("en-us"))
{
Response.Redirect("Default.aspx?lenguaje=en");
}
else
{
Response.Redirect("Default.aspx?lenguaje=es");
}
}
}
}
}
private void cargaComboLenguajes()
{
if (Session["cmbIdioma"].ToString() != "")
{
cmbIdioma.SelectedValue = Session["cmbIdioma"].ToString();
}
else
{
cmbIdioma.SelectedValue = "en-us";
Session["cmbIdioma"] = "en-us";
}
}
protected void cmbIdioma_SelectedIndexChanged(object sender, EventArgs e)
{
string language = cmbIdioma.SelectedValue;
if (!string.IsNullOrEmpty(language))
{
Session["cmbIdioma"] = cmbIdioma.SelectedValue.ToString();
Response.Redirect("Default.aspx?lenguaje=" + Session["cmbIdioma"].ToString());
}
}