locked
InitializeCulture only once instead of in every page? RRS feed

  • Question

  • User-1246604461 posted

    I have a mutlilanguage website and right now in every page, I have to do this to show the correct culture:

       Protected Overrides Sub InitializeCulture()
            Dim cultureInfo As Globalization.CultureInfo = GetLanguage(Request.Url.ToString) 'Globalization.CultureInfo.CreateSpecificCulture("nl")
            Threading.Thread.CurrentThread.CurrentCulture = cultureInfo 'to format dates, numbers etc
            Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo 'looking up culture specific strings
            MyBase.InitializeCulture()
        End Sub

    Couldnt I place that in global.asax or masterpage somehow so that I only have to do it once and that every new page automatically is set to correct culture instead of me having to add the above every time?  

    Tuesday, May 3, 2011 3:34 AM

Answers

  • User-1246604461 posted

    I now used the global.asax application_beginrequest to determine what culture to use.thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 4, 2011 2:56 AM

All replies

  • User1401801381 posted

    Do it in the main web.config file

     

       <system.web>
          <globalization culture="en-US" uiCulture="nl"/>
       </system.web>
    Tuesday, May 3, 2011 3:44 AM
  • User-1246604461 posted

    I now used the global.asax application_beginrequest to determine what culture to use.thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 4, 2011 2:56 AM