Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know we can use localization pattern in ASP.NET pages which makes possible to have multi-language web application. I tried same technique for Master page but it does not work.

I have a login page, and in the login page there is option to select language for the website

and if the login is successfull,then redirecting to home page...

Login page is a stand alone page, but the rest include Homepage is having a masterpage

the masterpage have 5/6 linkbuttons.

The thing is, i want to change the text of those 6 linkbuttons according to language selected at login page.



I googled hardly, and nothing found helpfull

Any idea?
Thanks

The code i used is


C#
protected override void InitializeCulture()
   {
       string currentCulture =Convert.ToString(Session["Language"].ToString());
       if (!string.IsNullOrEmpty(currentCulture))
           currentCulture = currentCulture;

       else

       currentCulture = "en-US";
       Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentCulture);
       Thread.CurrentThread.CurrentUICulture = new CultureInfo(currentCulture);

       base.InitializeCulture();
   }
Posted

Hi,

refer the below article.
Multi-lingual web applications using ASP.Net 4[^]

hope it helps.
 
Share this answer
 
What about following CodeProject article:
Developing an ASP.NET page with MasterPage and Localization[^]
I found it by googling for master page localization...
Originally, I thought that that "hardly" in "I googled hardly" was a grammar error.
 
Share this answer
 
Comments
kishore Rajendran 25-Apr-13 6:14am    
Thats not the correct link
StianSandberg 25-Apr-13 6:25am    
what is wrong with that link?
kishore Rajendran 25-Apr-13 6:41am    
I asked to change the language of a masterpage using the language code stored in a session variable. The link given above shows changing language FROM masterpage.
means, i want to change language of a masterpage on its page load

Thanks
StianSandberg 25-Apr-13 6:44am    
hmm.. The article explains how to set Culture based on a sessionvariable in protected override void InitializeCulture() I think that's a good answer.
kishore Rajendran 25-Apr-13 6:46am    
yes...but dont think i will post a question before a well defined google search.
like Bernhard Hiller told
Put the code in the page load of masterpage

C#
protected void Page_Load(object sender, EventArgs e)
    {
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(Session["Language"].ToString());
        //System.Threading.Thread.CurrentThread.CurrentCulture =
        //ci;
        System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

    }



Here Session["Language"] contains the language code. and it is stored to the session variable
from login page





Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900