Tony Wu Tony Wu - 2 months ago 12x
ASP.NET (C#) Question

How to make my webform to be multi-language?

I am going to write a web form via Visual Studio 2013 with Devexpress v14.1.

The web form is required to change the language with CheckedChanged event.

I have read some of the articles from Google,
but it seems that it required to set all of the controls one by one.

For example, if there are 30 labels in my web page, it is necessary to add 30 lines:

Label1.Text = ...;

Label2.Text = ...;


Label30.Text = ...;

What is the best approach to make multi-language web page ?

Please help!!!


Implementing multi-lingual is not as simple as you think.

Prerequisite: -

All controls which need multi-lingual on your page should be server control. e.g.

<Label runat="server" ID="lblName" Text="Type your name"></Label>
  1. Create a resource file

To generate a local resource file from an ASP.NET Web page

  1. Open the page for which you want to create a resource file.

  2. Switch to Design View.

  3. In the Tools menu, click Generate Local Resource. (It will create the a resource file in local resources folder)

  4. Type values for each resource that you need in your application, and then save the file.

Read more Creating Resources From a Web Page

  1. When you have successfully created a default resource file (e.g. mypage.resx) then copy/paste it and rename the copied file with the language specific e.g. for french

  2. Change the values to the language specific values uses the resx file based on the current thread culture but the problem is CheckedChanged event occurs after the Page_Load event so CheckedChanged event method is not the correct place to change thread culture.

So you will need to capture the CheckedChanged value manually in Page_Init event (which occurs before Page_Load) event from Request.Form values and set the culture

Or inside CheckedChanged save a value in session or cookie and reload the page and in Page_Init use the session/cookie value to set the thread culture