For example, I have a Login page with two labels and two Textbox on it. The page is named Login. aspx, and the control is named lbl_UserName, lbl_Password, txt_UserName, and txt_Password.
First, you can create a new App_LocalResources folder on the website, and then create a new resource file named Login. aspx. resx
The name must be the same as that of the matched page. Create another resource file named Login. aspx. zh-Cn.resx.
Login. aspx. resx is the default, while Login. aspx. zh-Cn.resx is called when the browser's default language is set to Chinese.
Open the Login. aspx. resx file:
NAME value
LabelResource1.Text Username
LabelResource2.Text Password
Open the Login. aspx. zh-Cn.resx file:
NAME value:
LabelResource1.Text Username
LabelResource2.Text Password
Then, in our page code
Set
1 <asp: Label ID = "lbl_UserName" runat = "server"> </asp: Label>
2 <asp: Label ID = "lbl_Password" runat = "server"> </asp: Label> changed
1 <asp: Label ID = "lbl_UserName" runat = "server" Text = "<% $ Resources: LabelResource1.Text %>"> </asp: Label>
2 <asp: Label ID = "lbl_Password" runat = "server" Text = "<% $ Resources: LabelResource2.Text %>"> </asp: Label>
3
Finally, in the Page attribute of the Page, add the "Culture =" auto: zh-Cn "UICulture =" auto: zh-Cn ", which is set to Chinese by default.
After compilation, you can see the effect. When the default language of the browser is English, you can see that the two labels are displayed as Username and Password.
When the default language of the browser is Chinese, you can see that the two labels are displayed as the user name and password.