Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP .Net Page with two languages

ASP .Net Page with two languages

Scheduled Pinned Locked Moved ASP.NET
csharp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FJJCENTU
    wrote on last edited by
    #1

    I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards

    T J 2 Replies Last reply
    0
    • F FJJCENTU

      I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      A simple hack would be to redirect back to the same page in the click handler.

      F 1 Reply Last reply
      0
      • T T M Gray

        A simple hack would be to redirect back to the same page in the click handler.

        F Offline
        F Offline
        FJJCENTU
        wrote on last edited by
        #3

        I don`t understand your meaning for "a simple hack" but my problem is that InitializeCulture executes before than Button_click so the first click on the button first execute the InitializeCulture before the culture has changed (Session["Culture"]) and the second click just really change the page, but how to do it in only one click.

        1 Reply Last reply
        0
        • F FJJCENTU

          I am working with a page which needs to change it's language by user decission, so I created the Local Resources and I want link the language to an imageButton with the country flag, and I change the Culture data inside the button click event and overrides the InitializeCulture Method, and it works, but because InitilizeCulture executes before than the click event it needs two clicks for getting the page change, my InitializeCulture method contains the following sentences: protected override void InitializeCulture() { if (Session["Cultura"] != null) { Cultura = (string)Session["Cultura"]; UICulture = Cultura; if (Cultura == "es") Culture = "es-ES"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(Cultura); } base.InitializeCulture(); } What I need to introduce in order to avoid the double click, because the execution order normally is InitializeCulture - Page_Load - Button_click, and if I directly call the InitializeCulture from the Button_Click it doesn't refresh th screen. Best Regards

          J Offline
          J Offline
          Jamil Hallal
          wrote on last edited by
          #4

          Hi, i propose to move the code that update the Session["Cultura"] to code block of Button_Click and let the InitializeCulture() do it is job by setting the CurrentUICulture.

          Regards, Jamil

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups