0

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.

1 Answer 1

2

My suggestion to get around this is to use AJAX. Asynchronisly call your ChangeLanguage function when the language literal gets clicked.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.