Answered by:
Globalization - with Masterpages

Question
-
User749469198 posted
hi all,
i want to set two different languages (e.g. en, de) for my webapplication (global - for all pages).
In Masterpage i have a radiobuttonlist with 2 listitems. I have read a lot about
In my web.config i have<globalization culture="Auto" uiCulture="Auto"/>
What is the best way (simplest way) to set the language for all pages?
Do i have to use a BasePage Class - is there a way without using basepage
When i use global.asax must i have the web.config entry<globalization culture="Auto" uiCulture="Auto"/>
Thanks a lot
How can i store the actual language in a session
Wednesday, March 18, 2009 4:10 AM
Answers
-
User749469198 posted
ok , thanks
so i´ve spent a lot time - to figure out the shortest and best way for me.
here is my solutionStep 1
Creating a BaseClass
Protected Overloads Overrides Sub InitializeCulture() Try Dim currentCulture As String = Convert.ToString(Session("userCulture")) If Not String.IsNullOrEmpty(currentCulture) Then currentCulture = currentCulture Else currentCulture = "en-US" End If Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentCulture) Thread.CurrentThread.CurrentUICulture = New CultureInfo(currentCulture) MyBase.InitializeCulture() Catch ex As Exception End Try End Sub
for example i use a radiobuttonlist to let user change the language
Step 2
inherits for e.g. defautl.aspx from BaseClassPartial Class _Default Inherits BaseClass End Class
Step 2
Protected Sub RadioButtonList_Language_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList_Language.SelectedIndexChanged Try Session("userCulture") = RadioButtonList_Language.SelectedValue Server.Transfer(Request.Path) Catch ex As Exception End Try End Sub
i hope this will help someone - for me it works perfect
Thanks
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 20, 2009 5:52 AM
All replies
-
User1837974337 posted
follow these links
http://www.codeproject.com/KB/aspnet/GlobAndLoc.aspx
http://www.codeasp.net/articles/asp.net/29/globalization-and-localization-demystified-in-aspnet-20
Wednesday, March 18, 2009 6:19 AM -
User749469198 posted
ok , thanks
so i´ve spent a lot time - to figure out the shortest and best way for me.
here is my solutionStep 1
Creating a BaseClass
Protected Overloads Overrides Sub InitializeCulture() Try Dim currentCulture As String = Convert.ToString(Session("userCulture")) If Not String.IsNullOrEmpty(currentCulture) Then currentCulture = currentCulture Else currentCulture = "en-US" End If Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentCulture) Thread.CurrentThread.CurrentUICulture = New CultureInfo(currentCulture) MyBase.InitializeCulture() Catch ex As Exception End Try End Sub
for example i use a radiobuttonlist to let user change the language
Step 2
inherits for e.g. defautl.aspx from BaseClassPartial Class _Default Inherits BaseClass End Class
Step 2
Protected Sub RadioButtonList_Language_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList_Language.SelectedIndexChanged Try Session("userCulture") = RadioButtonList_Language.SelectedValue Server.Transfer(Request.Path) Catch ex As Exception End Try End Sub
i hope this will help someone - for me it works perfect
Thanks
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, March 20, 2009 5:52 AM -
User-2060258345 posted
Thanks for your help, I will opt for this too I think.
Tuesday, February 9, 2010 4:42 AM