Last post Aug 18, 2006 03:39 AM by Gordon-Freeman
Aug 17, 2006 03:36 AM|arco|LINK
I was trying to make my site dynamically localizable. When user clicks some linkbutton, application should change UICulture and render the pages depending on new settings.
I've tried to do this in PageLoad and on Init but both didn't work.
The Session["lang"] is set to what I need, when that line executes, so that's right. And after this line CurrentThread.CurrentUICulture is set to what I need too!
But I don't get my page rerendered using new UICulture!
Please Help Me On This!
PS. I'm using MasterPage, but neither master page nor child pages render the way I want.
Aug 18, 2006 01:48 AM|Gordon-Freeman|LINK
Hi~ There is the faq you needed~
Basically MasterPage is derived form UserControl but not Page class, so there is no UICulture and Culture property or InitializeCulture() for it.
You can create Global.asax, in Application_BeginRequest(), read culture setting from where you stored it, then set Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture. This is because BeginRequest is touched off before the MasterPage's
Aug 18, 2006 03:30 AM|arco|LINK
Thanx for advice! I've solved the problem yesterday by overriding InitializeCulure() method of a page.
And thus it occurs before masterpage is rendered, the master page localizes too. So, that's fine.
But now I have another problem - how to intercept Click event of some asp:LinkButton control before InitializeCulture executes? Or how do I get information about what was clicked on a page in InitializeCulture() method?
The perfect scenario for me is when I have two LinkButtons on the master page. When user clicks on 1st one - language changes to some lang1, when he(she) clicks on 2nd one - language changes to lang2.
But InitializeCulture() is overriden in Page class. How to make that work the way I want?
Thanx for any help!
Aug 18, 2006 03:39 AM|Gordon-Freeman|LINK
I'm not sure whether this will work, but you can have a try: