I added to my website in vb.net a LocalResource with a translated content in .resx archives. The translation works properly based on the browser language but i want to change the language from the same page. For this I added the following code in the button event: System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("fr-FR") System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("fr-FR") System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("fr") System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr")
It does not work, the page stills with the same language.
The problem was that i can't put "Protected Overrides Sub InitializeCulture()" in the master page, therefore, i have to put initializeculture in all the aspx pages?
vfortuny
Member
2 Points
2 Posts
Change vb.net website language from button event
Aug 14, 2011 11:11 AM|LINK
rezaxp
Participant
1879 Points
370 Posts
Re: Change vb.net website language from button event
Aug 14, 2011 11:27 AM|LINK
you have to set resources to your controls
see :
http://msdn.microsoft.com/en-us/magazine/cc163566.aspx
Life would be so much easier if we could just look at the source code.
Tweet
Yanping Wang...
Star
14919 Points
1537 Posts
Microsoft
Re: Change vb.net website language from button event
Aug 16, 2011 06:13 AM|LINK
Hi vfortuny,
Please refer MSDN article about how to set the current UI culture and current culture
http://msdn.microsoft.com/en-us/library/bz9tc508(v=VS.85).aspx
Hope this helps, thanks.
Feedback to us
Develop and promote your apps in Windows Store
vfortuny
Member
2 Points
2 Posts
Re: Change vb.net website language from button event
Aug 16, 2011 06:19 AM|LINK
Hi,
The problem was that i can't put "Protected Overrides Sub InitializeCulture()" in the master page, therefore, i have to put initializeculture in all the aspx pages?
Mamboking
Member
183 Points
125 Posts
Re: Change vb.net website language from button event
Aug 16, 2011 04:43 PM|LINK
You can do as follow:
1. Put button "Change language" to master page.
2. Put handler that get button event of master page to your .aspx page
3. Put in the handler you code for change culture.
I believe you easily can find sample of getting event from master page on asp.net learn chapters