Last post Mar 24, 2006 04:14 PM by lucasp
Feb 08, 2006 07:23 PM|lucasp|LINK
Feb 17, 2006 07:02 AM|Flo1973|LINK
Create a new class and derive it from System.Web.UI.Page. In this class override InitializeCulture(). Then derive all your other Pages from this new class. For example:
public partial class localizedPage : System.Web.UI.Page
protected override void InitializeCulture()
public partial class myPage : localizedPage
Mar 07, 2006 05:32 PM|lucasp|LINK
Mar 08, 2006 04:58 AM|rmprimo|LINK
check these out
Mar 08, 2006 07:16 AM|Flo1973|LINK
This is what I do. I use a property named "Language" to store the users preference. Place this code in your new class (localizedPage) and derive all the other pages from this class. Should work.
Mar 08, 2006 10:59 AM|lucasp|LINK
Mar 08, 2006 11:51 AM|lucasp|LINK
Mar 08, 2006 12:00 PM|rmprimo|LINK
This only works if the page that sets the profile is dedicated. In order to set the profile you need some sort of an input control. This page will then be ALWAYS ONE CULTURE BEHIND, in the history of changing cultures. It is kind of ok, it
is just one page exception to the rule. This one page can be done DIRECTLY, via the Request.Form collection as described in this
video demo, just set the profile too.
It is not the form of persistence(you chose the profile, which is fine) but the fact that InitializeCulture() occurs early on when there are no controls yet, so whichever the persistence medium, it would be reading yesterdays news.
You can build the dropwdown into the OO hierarchy. Its(any control's) members are not available yet for the InitializeCultue method, so you need to use the Request.Form collection. This is a real coupled solution though and limited as to UI
Putting the dropdown to be in the MasterPage. Then every page becomes the exception to the rule.
See the links I pointed to for a solution.
Another way to solve this is a design with iframes(frown, frown). Then the parent page with the dropdwon set the cullture directly. The child page loads properly because that request occurs after the parent. The child page can use OO and of the ways of persistence. As
a matter of fact I use complex navigational system and not to repost it, I keep it in the parent page. Frames are a huuuge hassle though, and far from best practices. MSDN uses frames because the navigational system requires it, but they are not for the faint
Bottom line what you are asking for is not simple but doable. Under all scenarios it is either coupled or brittle, which is why Microsoft didn't offer it as a canned feature. Microsoft pushes the "AUTO" feature which essentially persists in a browser setting
which is always available early on, and if switched, it occurs BEFORE the request, as it is done in the browser GUI and not even the page itself. We all agree "auto" is the lamest of all, until they expose the browser setting to scripting, which will be NEVER,
for security reasons.
Mar 08, 2006 12:15 PM|rmprimo|LINK
I would prefer not to rely on cookies
Luca, it is not the cookies. You can use any of the persistence forms you like.
BTW, what do you think profile uses by default? Last I looked, http is still disconnected so you still need to identify yourself on every request.
Look for the stats for users that accept cookies? Virtually 100% :)
Mar 08, 2006 12:31 PM|Flo1973|LINK
I agree, and this is what I do. I have got a dropdown control for choosing the language in my masterpage. When the selection index is changed, then in set the new profile value and reload the page. Sorry, I forgot to mention this...
Mar 08, 2006 12:37 PM|lucasp|LINK
Mar 24, 2006 04:14 PM|lucasp|LINK