Essayflow goes over the full essay creating procedure - from organizing and likely to conclusion. Composing essays is organised gradually so i highly recommend that you use it this way. On the other hand, you will see coming from the sidebar that this guideline is split into several help me write an essay that it is separated into reduced parts or subsections. Allowing you to often study it right thru from beginning to end or go directly to the area that’s most relevant to you. You will notice in the topbar choices higher than that additionally there is a glossary of terms employed in this article; and a list of encouraged additionally reading through and internet based information. It can do not deliver comprehensive advice on typical study capabilities although it does deal with some areas of reading for crafting and the way compose a literature assessment. Not like some instructions, that one does not have everything to say about using computing devices with the exception of: make use of them, and keep your operate often.

C#.NET Localization with MasterPage

I recently started programming using C#.NET. The first thing I had to do with it, is make a complete website, kinda cool to learn about the language! At first it was easy, but then I had to localize the website for French and English. After hours of reading, I found a suitable solution written by Michael Ulmann.

  1. Open up your Website in Visual Studio
  2. Open up Global.asax and add these lines
    void Session_Start(object sender, EventArgs e)
    {
        /*
         * Set the default language of the website
         * In my case it is en-CA, but you could put anything
         */
        Session["MyCulture"] = "en-CA";
    }
  3. Create two links in your MasterPage.master
    <asp:linkbutton
        onclick="changeCulture_Click"
        commandargument="fr-CA"
        text="Français"
        runat="server"
        id="btnSetFR"/>
    <asp:linkbutton
        onclick="changeCulture_Click"
        commandargument="en-CA"
        text="English"
        runat="server"
        id="btnSetEN"/>
  4. Add the Click Event to your MasterPage.master.cs
        protected void changeCulture_Click(object sender,
           EventArgs e)
        {
            LinkButton senderLink = sender as
                LinkButton;
    
            Session["userCulture"] =
               senderLink.CommandArgument;
    
            Server.Transfer(Request.Path);
        }
  5. Create a new C# Class in App_Code, name it BasePage.cs and copy this code in it.
        public class MyPage : Page
        {
            protected override void InitializeCulture()
            {
                /*
                 * Get the culture from the Sessions
                 */
                string currentCulture =
                    Convert.ToString(Session["userCulture"]);
    
                /*
                 * Check if there's in a
                 * culture in the Sessions
                 * Otherwise, set the Default Culture
                 */
                if (!string.IsNullOrEmpty(currentCulture))
                    currentCulture = currentCulture;
                else
                    currentCulture = "en-CA"; 
    
                /*
                 * Apply the Culture to our thread.
                 */
                Thread.CurrentThread.CurrentCulture =
                    CultureInfo.CreateSpecificCulture(
                        currentCulture
                    );
    
                Thread.CurrentThread.CurrentUICulture =
                    new CultureInfo(currentCulture);
    
                base.InitializeCulture();
            }
        }
  6. Change the inheritance of all your web forms from Page to BasePage
  7. Now all you need to do is create your Resources in GlobalResources and LocalResources Folders

As I said, I learned this from an article posted on CodeProject by Michael Ulmann. If you would like to read the original article or download the source code, follow this link

Tags: , ,

This entry was posted on Sunday, August 31st, 2008 at 1:02 pm and is filed under ASP.NET, Developement, Globalization. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “C#.NET Localization with MasterPage”

Kiki August 17th, 2009 at 6:22 pm

Thanks, that’s what I needed!!!

Tim May 9th, 2011 at 8:50 am

How do you change the inheritance of all your web forms from Page to BasePage? I keep getting errors. Could you append that to the tutorial. It would be very helpful.

Leave a Reply