Last post Dec 29, 2005 08:18 PM by rmprimo
Dec 29, 2005 02:58 PM|hcaudill|LINK
I'm adapting a website built in 1.1 to 2.0, and trying to do so without rewriting my exisiting class library, which includes a lot of localization stuff. In particular there is a LanguageMenu object that uses some custom logic (based on who's signed in,
the browser's language preferences, etc.) to set the culture. This takes place during Page.Init; the code used is pretty standard:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Name)
Thread.CurrentThread.CurrentUICulture = New CultureInfo(Name)
So far so good; the following markup on a page retrieves the correct resource for the selected culture:
Strangely, though, the <%$ Resources:... %> syntax always returns the default culture's resource (in this case, the English string).
<asp:textbox runat="server" id="SignupEmail" text="<%$ Resources:AppStrings,txtFoo %>" />
When I have these two bits of markup on the same page, the first generates the correct localized string; the second generates the English string. Any ideas what might be going on? Does the <%$ .. %> tag get bound before Page.Init fires?
Dec 29, 2005 08:18 PM|rmprimo|LINK
The resource expressions are evaluated very early, unlike databinding expressions. So if you put you thread setting code in
Application_BeginRequest in Global.asax it should work. It does force you to globalize the logic though, so if you still want the per page flexibility, you would have to pass on the declarative expressions.