How to create the Multilanguage application in



We can create the Multilanguage application in like this

Step 1: Add the Master Page Site1.Master and Design the Menu and language Selection dropdown list like this

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="MultilanguageSample.Site1" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <style type="text/css">
        html {
            font-family: Tahoma;
            font-size: 14px;
            font-style: normal;
            background-color: Silver;

        .Content {
            margin: auto;
            width: 700px;
            background-color: white;
            border: Solid 1px black;
        .auto-style1 {
            width: 100%;
    <asp:ContentPlaceHolder ID="head" runat="server">

    <form id="form1" runat="server">
        <div class="Content">
        <br />
            <table class="auto-style1">
                    <td style="background-color: #339966"> <a href="Default.aspx">
                <asp:Label ID="Label1" meta:resourcekey="menuItemDefault" runat="server" Text="Home"></asp:Label>
                    <td style="background-color: #339966; " ><a href="Contact.aspx">
            <asp:Label ID="Label2" meta:resourcekey="menuItemContact" runat="server" Text="ContactUs"></asp:Label>
                    <td style="background-color: #339966;"><asp:DropDownList ID="DropDownList_Language" runat="server" Height="20px" Width="170px"
            OnSelectedIndexChanged="DropDownList_Language_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Value="en-US">English</asp:ListItem>
            <asp:ListItem Value="sv-SE">Swedish</asp:ListItem>
        <br />
        <br />

            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

Step 2: Write the code in code behind file like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MultilanguageSample
    public partial class Site1 : System.Web.UI.MasterPage
        protected void Page_Load(object sender, EventArgs e)
            if (Session["language"] != null && !IsPostBack)
                DropDownList_Language.Items.FindByValue(Session["language"].ToString()).Selected = true;
        protected void DropDownList_Language_SelectedIndexChanged(object sender, EventArgs e)
            switch (DropDownList_Language.SelectedValue)
                case "en-US": this.SetMyNewCulture("en-US");
                case "sv-SE": this.SetMyNewCulture("sv-SE");
        private void SetMyNewCulture(string culture)
            Session["language"] = culture;

Note: Here you can also store the user language selection in cookies or Local Storage of Html 5 using JavaScript. This can be used to maintain the user preference language at page Load.

Step 3 : Create a “App_LocalResources” folder and add the resources as page wise Like Site.master .resx for English and resx for Swedish

Note: Keep the separate resource file for each page for better maintainability.


Step 4: Add this method in global.asax file

void Application_AcquireRequestState(object sender, EventArgs e)
           HttpContext context = HttpContext.Current;
           if (context.Session["language"] != null)
               Thread.CurrentThread.CurrentUICulture = new CultureInfo(context.Session["language"].ToString().Trim());
               Thread.CurrentThread.CurrentCulture = new CultureInfo(context.Session["language"].ToString().Trim());

This is used for getting the current state of session.

Step 5: Call the resource key on label like this as a page wise.

You call also call the resource file in C# like this

protected void Page_Load(object sender, EventArgs e)
          lblMsg.Text = GetLocalResourceObject("lblMsgHome.Text").ToString();


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.