Last post Aug 11, 2010 01:33 AM by prakher_prakher
Aug 10, 2010 04:24 PM|Nullio|LINK
I have a site that needs to support 2 cultures, "en-US" and "fr-CA" an there needs to be a link at the bottom that can switch between the two cultures. To do this I store the current culture in a session variable and have a link button that changes the value.
Then I override the pages InitializeCulture with the following
protected override void InitializeCulture()
if (Session["PageCulture"] == null)
Session["PageCulture"] = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo((string)Session["PageCulture"]);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo((string)Session["PageCulture"]);
This works except for validation errors that are stored in resource files. When I switch to a different culture the validation errors are always in the default culture. Does anyone know why?
Also as a question of interest wouldn't changing the System.Threading.Thread.CurrentThread's culture change the culture for all clients running on that thread or does it do just the current request?
Aug 11, 2010 01:33 AM|prakher_prakher|LINK
The validation error values are set at the time of initial page load. When you are changing the culture.. its causing a post back and putting the culture information in session.. if you want the changes to reflect in the validation errors. you will have
to reassign the error messages after the culture change.
Also when you change the culture, it gets changed for the current session and not for all other sessions.