I have an asp:literal:
<asp:Literal id="language" OnClick="changeLangauge" Text="<%$ Resources:Translate, switchLanguage %>" runat="server"/>
When it is clicked it switches the language:
public void ChangeLanguage(Object sender, EventArgs e)
{
string lang = langauge.Attribues["class"];
language.Attributes.Remove("class");
if (lang.Equals("fr-CA"))
{
language.Attributes.Add("class", "en-US");
Session["lang"] = "en-US";
}
else
{
language.Attributes.Add("class", "fr-CA");
Session["lang"] = "fr-CA";
}
}
I have overrided InitializeCulture, to set the culture based on Session["lang"]. The problem is InitializeCulture gets called before ChangeLanguage. How do I get around this problem?
I have tried to get the class value from asp:Literal control from inside InitializeCulture like this:
public void InitializeCulture(..)
{
...
String selectedLanguage = Request.Form["language"]
...
}
but it always returns null.