What is Globalization and Localization in ASP.Net

Before starting, let's get these two terms straight.

Globalization is the process of designing the application in such a way that it can be used by users from across the globe (multiple cultures).

Localization, on the other hand, is the process of customization to make our application behave as per the current culture and locale. These two things go together.

To do globalization we need to use Resource Files.

Let's Start
To add Resource Files to our project:

  1. Right-click on the Root Folder Add New Item.
  2. Select Resource File from the above Templates.
  3. Name it "Resource.resx"
  4. You need other Resource Files for storing data depending on the Culture
  5. Add another file with the following names of each resource, such as "Resource.en-GB.resx" else you can give a different name but after the (Dot ) because they are sub-files of "Resource.resx".
    • For English you can add "Resource.en-GB.resx"
    • For Marathi you can add "Resource.mr-IN.resx"
    • For Hindi you can add "Resource.hi-IN.resx"
    • For Arabic you can add "Resource.ar-SA.resx"

Localization and Globalization1

Localization and Globalization2

Localization and Globalization3

1. Let us add some data in these files; open "Resource.resx"

Add a name under the "Resource.resx" Filename Column and keep the Value column blank as in the following:

Save And Close  Resource.resx
Save And Close Resource.resx

2.  Open "Resource.en-GB.resx"

  • Add a name under the "Resource.en-GB.resx" Filename and the value that you want to display in the value field.


Open Resource.en-GB.resx

3. Open Resource.hi-IN.resx

  • Add a name under the "Resource.hi-IN.resx" Filename and the Value that you want to display in the value field.

Open Resource.hi-IN.resx

4. Open "Resource.mr-IN.resx"

  • Add a name under the "Resource.mr-IN.resx" Filename and the Value that you want to display in the value field.

Open Resource.mr-IN.resx
5. Open "Resource.ar-SA.resx"

  • Add a name under the "Resource.ar-SA.resx" Filename and the Value that you want to display in the value field.
Open Resource.ar-SA.resx


  • Add a new page and name it "LocalPage.aspx"
  • Add a DropDownList in the "LocalPage.aspx"

On LocalPage.aspx

<asp:DropDownList ID="DrpLanguages" AutoPostBack="true"

 runat="server" Width="200px"


<asp:ListItem Text="Select Languages" Value="0"></asp:ListItem>

<asp:ListItem Text="English" Value="en-GB"></asp:ListItem>

<asp:ListItem Text="Hindi" Value="hi-IN"></asp:ListItem>

<asp:ListItem Text="arabic" Value="ar-SA"></asp:ListItem>



protected void DrpLanguages_SelectedIndexChanged(object sender,EventArgs e)


    Session["Culture"] = DrpLanguages.SelectedValue;



  • Add another page name ("Runpage.aspx")

  • Add a Label to this "Runpage.aspx"

Add two Labels

For accessing the resource file you need to add syntax like this:

"<%$Resources:Your Main Resource file Name, Add Name Of Resource field which you want to display %>"

<asp:Label ID="lblresdisplay" Font-Size="Large" runat="server"                   Text="<%$Resources:Resource,AccCode%>"></asp:Label>

<asp:Label ID="Label1" Font-Size="Large" runat="server" Text="<%$Resources:Resource,AccCode%>"></asp:Label>

To accomplish this, what we need to do is to override the InitializeCulture function and set the UICulture to the user selected language.


using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Globalization;

using System.Threading;


public partial class Runpage : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)





protected override void InitializeCulture()



        System.Threading.Thread.CurrentThread.CurrentCulture = new   System.Globalization.CultureInfo(Session["Culture"].ToString());

        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Session["Culture"].ToString());




Final Output

Output Localization and Globalization1

Output1 Localization and Globalization1

Up Next
    Ebook Download
    View all
    View all