[Selected from: http://msdn.microsoft.com/library/cht/default.asp? URL = / library / cht / vbcon / html / vbwlkwalkthroughlocalizingwebforms.asp]
The Visual Studio system does not automatically generate resource files when you use the Web Form web page. You must manually establish and edit XML resource files. This topic will demonstrate how to join the resource file, then use XML editing, establish a resource in English, Chinese. This topic also discusses how to write procedures for accessing these resources.
You can also convert text content into resource files. For details, see the resource and resource file generator (ResGen.exe) text format.
A. How to create and edit resource files manually
1. Establish an ASP.NET web application called LocProject. For details, see Establishing a web project.
Note: Project name will be used in the program LocProject
2. In the project, join the new item (Add New Item ...)
3. Select "Assembly Resource File. The file name is Strings.resx (there is no "in the middle of the name.", Otherwise, it is easy to erroneously). The resource file Strings.resX will contain the original resources of English. These resources will be accessed whenever the app is more suitable for the UI cultural feature.
The file will be added to the project and open in the XML design tool.
4. In the "Data Tabls :) list, select" DATA ".
5. In the Data (Data :) page, add 2 lines of data TXTSEARCH and TXTWELCOME as follows:
Name ValuetXTSearch Search for the Following Text: Txtwelcome Welcome To Localization!
6. Repeat 1 time step 2 to 5, establish another data file named strings.en-chs.resx.resx, the data is as follows:
Name ValuetXTSearch Search String: TXTWELCOME Welcomes localization!
B. How to access resources
1. Add System.Resources and System.Globalization namespaces. The following code is as follows:
'Visual BasicImports System.ResourcesImports System.globalization
Public class Webform1 inherits system.web.ui.page
// c # using system.resources; using system.global;
Namespace LocProject
2. Declare the variable of the ResourceManager class LOCRM
'Visual Basic Public Class Webform1 Inherits System.Web.ui.page Protected Locrm As ResourceManager
// c # namespace LocProject_cs {public class Webform1: system.Web.ui.page {protected resourcemanager LOCRM
3. Add the following code to WebForm1 Method Page_Load to create an instance of the ResourceManager class. The ResourceManager constructor uses two parameters. The first is the root name of the resource file, that is, the resource file name without cultural characteristics and .resx suffix. The second parameter is the main component. 'Visual Basic LoCRM = New ResourceManager ("LocProject.strings", gettype (webform1) .assembly)
// c # LoCRM = New ResourceManager ("LocProject.strings", Typeof (WebForm1) .assembly);
Note: If you do not name the project is LocProject, you should modify the root name of the resource file.
C. How to display a static resource string in the page
Place the code between the