ASP .Net Page with two languages
-
I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards
-
I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards
-
I don`t understand your meaning for "a simple hack" but my problem is that InitializeCulture executes before than Button_click so the first click on the button first execute the InitializeCulture before the culture has changed (Session["Culture"]) and the second click just really change the page, but how to do it in only one click.
-
I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards
Hi, i propose to move the code that update the Session["Cultura"] to code block of Button_Click and let the InitializeCulture() do it is job by setting the CurrentUICulture.
Regards, Jamil