Click here to Skip to main content
12,508,996 members (59,920 online)
Click here to Skip to main content
Add your own
alternative version

Stats

21.7K views
581 downloads
19 bookmarked
Posted

Implement Multi Language Support for Client Side Validations in ASP.NET 3.5

, 13 Apr 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
This article demonstrates how to develop multi language page at server side as well as client side

Introduction

This article talks about how to develop a multilingual web page in Visual Studio 2008 and enable client script exposed alert messages based on respective language.

Background

A few days ago, I was working on my applications to enable them for multiple languages (English, French and Japanese) to address audiences of different regions.

Enabling an aspx page for multiple languages is very easy and for doing so, we need to maintain resource files (*.resx) for each and every language, and easily generate resource file(s).

To generate resource files, open aspx page in design mode, then go to Tools-->Generate Local resource.

Generatelocalres.JPG

This will create a meta resource key for all string values in a resource file and same entry inserted in markup, like:

<asp:Label ID="lblcname" runat="server" Text="Customer Name: *" 
	meta:resourcekey="lblcnameResource1" />

Now we need to override InitializeCulture at the page level:

protected override void InitializeCulture()
        {
            string culture = string.Empty;
            culture = Request.Form["ddlLang"];
            if (string.IsNullOrEmpty(culture)) culture = "Auto";
            UICulture = culture;
            Page.Culture = culture;
            if (culture != "Auto")
            {
                CultureInfo ci = new CultureInfo(culture);
                Thread.CurrentThread.CurrentCulture = ci;
                Thread.CurrentThread.CurrentUICulture = ci;
            }
        }

License

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

Share

About the Author

Aneesur Rehman Khan
Team Leader
India India
Anees is working as Sr. Team Lead based in Delhi(India).He is Post graduated in Computer applications and science.

He is having around 11 years of design,analysis and coding experience in Sharepoint, ASP.NET, C#, VB.NET, SQL Server 2000/05, Reporting Services,Analysis Services,VB 6.0 and Crystal Reports.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralInteresting soltuion but... Pin
RawHid315-Apr-09 13:09
memberRawHid315-Apr-09 13:09 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160927.1 | Last Updated 13 Apr 2009
Article Copyright 2009 by Aneesur Rehman Khan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid