locked
Globalization - with Masterpages RRS feed

  • 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"/>

    How can i store the actual language in a session

      Thanks a lot
    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 solution

     

     Step 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
    
    Step 2
    inherits for e.g. defautl.aspx from BaseClass
    Partial Class _Default
        Inherits BaseClass
    
    End Class
     Step 2
      for example i use a radiobuttonlist to let user change the language
     
        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

  • User749469198 posted

     ok , thanks
    so i´ve spent a lot time - to figure out the shortest and best way for me.

    here is my solution

     

     Step 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
    
    Step 2
    inherits for e.g. defautl.aspx from BaseClass
    Partial Class _Default
        Inherits BaseClass
    
    End Class
     Step 2
      for example i use a radiobuttonlist to let user change the language
     
        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