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 ?
Implementing multi-lingual is not as simple as you think.
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>
To generate a local resource file from an ASP.NET Web page
Open the page for which you want to create a resource file.
Switch to Design View.
In the Tools menu, click Generate Local Resource. (It will create the a resource file in local resources folder)
Type values for each resource that you need in your application, and then save the file.
Read more Creating Resources From a Web Page
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.
mypage.fr.resx for french
Change the values to the language specific values
Asp.net 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
CheckedChangedvalue manually in
Page_Initevent (which occurs before Page_Load) event from
Request.Formvalues and set the culture
CheckedChangedsave a value in session or cookie and reload the page and in
Page_Inituse the session/cookie value to set the thread culture