Click here to Skip to main content
13,450,154 members (54,009 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 9 Dec 2007

Globalization & Localization

, 9 Dec 2007
Rate this:
Please Sign up or sign in to vote.
implementing multiple culture with master page


Globalization, Localization concepts in ASp.Net enable developers and end users to enhance the web application with specific or generic culture content or information. Like Globalization enables developers to design and develop applications that function for multiple cultures and Localization enables for customizing your application for a given culture and locale. In this precise article and sample file attached having few techincal terms which are explained below.


ASP.Net 2.0 can render the localized HTML for special browsers. It checks the "Accept-Language" HTTP header to identify the browser settings. To perform the localization, we can simply add the attributes for @Page or add globalization section in web.config file.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" UICulture="auto" %>


<!--// Web.config section under system.web-->

<globalization culture="auto" uiCulture="auto"/>

The differences between "Culture" and "UICulture" are Culture controls the formatting of dates, numbers, and currency whereas UICulture is for resource loading.

Using the code

I've made a sample to demonstrate the implementation of two cultures and languages Like, English and Arabic. Note : Arabic you'll find does not have any meanings, it is just for using Arabic language in ur application.

in this sample, there is a page named Default.aspx, which is inherited by the base page class managing the change in culture at user request. as the user presses the button to change in the culture Like English Or Arabic the base page class changes the current culture thread to the specified culture by the user.

            // Any source code blocks look like this
protected void lnkEnglish_Click(object sender, EventArgs e)


this.CurrentCulture = "en-US";

//pageDiv.Attributes.Add("dir", "ltr");


where as base class having the manual mechanism to change the contents on the web page to 
the specified culture.

<pre>in Default2.aspx there is a master page, which contains two link buttons for 
arabic and english. the change in the culture is managed by master with the same manual mechanism.
and in Default3.aspx file the culture is implemented by the generating the local Resource from 
Visual studio Menu -> Tools -> Generate Local Resource. this option generates the local resource for 
the current page with current page name like Default3.aspx.resx. I leave this page to readers to inherit
<pre lang="cs">this page with master page(having two link buttons for English and Arabic) and just change the culture 
by using the following methods. 

protected void lnkEnglish_Click(object sender, EventArgs e)


base.UICulture = "en-US";

Session["UIc"] = "en-US";



protected void lnkArabic_Click(object sender, EventArgs e)


base.UICulture = "ar-SA";

Session["UIc"] = "ar-SA";




protected override void InitializeCulture()




Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["UIc"].ToString());

Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;



catch (Exception ex)



You'll see a differnce from other two pages that this implementation is automatic. you donot need to 
do it manually as you've done in previous two pages.
NOTE : Uploaded are two files, One is having WebFiles and other contains a solution file. plz change a soltuion file settings by editing it into a notepad according to ur system local path for this project.


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


About the Author

Aqeel Khandwala
Web Developer
Pakistan Pakistan
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
hsnfrz29-Aug-12 1:26
memberhsnfrz29-Aug-12 1:26 
GeneralGlobalization & Localization Pin
aminamaq24-Jan-09 21:24
memberaminamaq24-Jan-09 21:24 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180318.3 | Last Updated 10 Dec 2007
Article Copyright 2007 by Aqeel Khandwala
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid