Click here to Skip to main content
15,565,747 members
Articles / Web Development / ASP.NET
Posted 8 Mar 2011


20 bookmarked

Globalization in ASP.NET 2.0

Rate me:
Please Sign up or sign in to vote.
4.25/5 (4 votes)
8 Mar 2011CPOL3 min read
How to create an ASP.NET Web application that can be adapted to different languages


Globalization is the process of designing and developing applications which can be adapted to different languages. Globalization is the process of designing and developing a software product that functions for multiple cultures.

If you want your website to be accessible in several languages in different regions, you should globalize it.


Globalization is a very efficient functionality that you can give to your website so that it can be adapted to different languages and regions.

A very good example you can see is the Google home page. There are different language options given below from which you can select one language and the whole site would adapt for that particular language.

How Would You Globalize Your Website in ASP.NET

Design your Page

Start Visual Studio 2005, go for a new website, name it ‘GloblizationEx’. First, design your website like a sample I have given below. Take 3 link buttons and a label. Change the text property of label to ‘Hello user let’s learn Globalization’ and change the text property of three link buttons to French, German, Russian.

Image 1

Now make click event of LinkButton1 by double clicking on it. Go to LinkButton2 property select event tab, select ‘LinkButton1_Click’ for click event. Repeat this for LinkButton3.

Add Resources Files

Now, you have to add resources file to your website, but first add a New Folder to your website and named it ‘resources’. For this, just go to solution explorer, right click on root and select ‘New folder‘. Now right click to this resources folder and select ‘Add New Item..’ option, Add New Item dialog box will appears, select ‘Resource File’ and named it ‘’. A message box will appear, click ‘No’ as given below:

Image 2

Now a screen appears. You have to enter Name and value for your resource file.

Enter ‘msg’ for Name and ‘bonjour utilisateur apprenons globlization’ for value field. Don’t worry, this msg is only French conversion of your message that you had given at your home page. Repeat these steps for German and Russian, file name will be ‘’ and ‘’ respectively. You can give value field for German and Russian as ‘hallo Benutzer lets lernen globlization’ and ‘@ hallo lernen globlization’ respectively. But Name field will be the same ‘msg’. Save all. A sample is given below:

Image 3

Note: You can translate your messages using Google More>>Translate tab.

Generate ‘.resources’ files.

Now you have to generate ‘.resources’ file. For this you have to open visual studio command prompt, you can find it at ‘visual studio 2005>> Visual Studio Tools’ menu. As you start Visual Studio command prompt, cmd screen appears. You have to locate ‘resources’ folder, like if you are creating your website in C drive with name ‘GloblizationEx’, you have to locate like ‘c:\Globlization\resources’ now type command ‘resgen’ for French resx file. Do it for German and Russian as ‘resgen’ and ‘resgen’ respectively.

Image 4

You can notice that .resources files are added to ‘resources’ folder.

Using the Code

You should use the following namespaces:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.IO;
using System.Globalization;

Now type the following code to click event (LinkButton1_Click) of LinkButton1.

protected void LinkButton1_Click(object sender, EventArgs e)
        string lanName="";
        LinkButton lnkBtn=(LinkButton)sender;

        switch (lnkBtn.ID)
            case "LinkButton1":
                lanName = "fr-FR";
            case "LinkButton2":
                lanName = "de-DE";
            case "LinkButton3":
                lanName = "ru-RU";
        System.Resources.ResourceManager rm = 
        ("strings", Server.MapPath("resources") + Path.DirectorySeparatorChar, null);
        CultureInfo cinfo = new CultureInfo(lanName);
        Label1.Text = rm.GetString("msg", cinfo);

Now just debug your website and click on ‘French’/’German’/’Russian’ link to change your welcome message.

Image 5


  • 8th March, 2011: Initial version 


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

Comments and Discussions

GeneralThis is not globalisation. Pin
Pete O'Hanlon9-Mar-11 2:47
mvaPete O'Hanlon9-Mar-11 2:47 
GeneralRe: This is not globalisation. Pin
Oakman14-Mar-11 13:13
Oakman14-Mar-11 13:13 
GeneralMy vote of 5 Pin
Sona s9-Mar-11 2:20
Sona s9-Mar-11 2:20 
GeneralMy vote of 2 Pin
Member 1319238-Mar-11 22:58
Member 1319238-Mar-11 22:58 
GeneralMy vote of 5 Pin
Ravi__Shankar8-Mar-11 19:51
Ravi__Shankar8-Mar-11 19:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.