What is the best practice to set the CurrentThread.CurrentUICulture
from a DrownDownList in a MasterPage?
I don't want to override InitializeCulture()
in every page.
Could 开发者_高级运维it be stored in a Session variable and set in a HttpModule or HttpHandler?
An additional problem i ran into is that if there are databound language-dependant controls on the page they will need to be databound after the language has changed.
Thanks.
I have most often chosen to create a pase page class and override InitializeCulture() there. All pages inherit from the base page so all logic is encapsulated in the base page. This works for me because I use the querystring to pass language preference changes.
InitializeCulture() has logic to check for querystring argument, existing session value, cookie preference, defaulting to the browser's current culture.
I suppose you could do a redirect in the masterpage dropdown change event.
I store the culture in a cookie and then set it in the Application_BeginRequest of the global.asax. When you first set it though you have to Server.Transfer(Request.Url.LocalPath) because the selectedindex changed event fires too late in the lifecycle to take affect. Not sure if its the best but it works for me.
精彩评论