locked
Localize on masterPage RRS feed

  • Question

  • User522004677 posted

    I am trying to localize the masterpage without success.

    on master page I have Image buttons, and on the behind code of the template master I have this code:

           protected void SetLangToEng(object sender, ImageClickEventArgs e)
          {
              HttpCookie cookie = new HttpCookie("Lang");
              cookie.Value = "en-US";
              Response.SetCookie(cookie);
          }
           protected void SetLangToHeb(object sender, ImageClickEventArgs e)
           {
               HttpCookie cookie = new HttpCookie("Lang");
               cookie.Value = "he-IL";
               Response.SetCookie(cookie);
           }
    
     

    in the GLOBAL.ASAX:

        void Application_BeginRequest(Object sender, EventArgs e)
        {
            string lang = string.Empty;//default to the invariant culture
            HttpCookie cookie = Request.Cookies["Lang"];
    
            if (cookie != null && cookie.Value != null)
            {
                lang = cookie.Value;
    
                System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(lang);
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(lang);
            }
             
        }

    When debugging on global.asax the lang set correct. do you have a clue what I am doing wrong?

    Friday, March 2, 2007 5:30 PM

Answers

  • User942311321 posted

    I would suggest creating a basepage class that all pages will inherit from. You an find a thread that explains this, explaining why to use the basepage method over the global.asax method. Good post . . . found here: http://forums.asp.net/thread/1545636.aspx

    If you need any more assistance, let us know. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2007 12:03 AM

All replies

  • User942311321 posted

    I would suggest creating a basepage class that all pages will inherit from. You an find a thread that explains this, explaining why to use the basepage method over the global.asax method. Good post . . . found here: http://forums.asp.net/thread/1545636.aspx

    If you need any more assistance, let us know. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2007 12:03 AM
  • User522004677 posted

    I know this thread and from there I got the idea of the global.asax

    but still it hust doesnt work. can you please help?

    Saturday, March 3, 2007 6:58 AM
  • User113421904 posted

      

    Try Page.PreInit Event.

    Tuesday, March 6, 2007 8:22 AM
  • User522004677 posted

    ok thanks, I used the previous solution it worx now.

     

    Tuesday, March 6, 2007 6:37 PM
  • User113421904 posted

    Hi,

    Dont forget to click "Mark as Answer" on the post that helped you. This can let other people know the problem have been solved.

    Tuesday, March 6, 2007 9:42 PM