1. Global Resource files are non-page-related resource files that can be accessed by the entire website.
For example, website maps and generic texts of a website can only be localized through global resource files.
2. It is easy to create and use a global resource file. Let's create an instance.
(1) Right-click the website project and choose "add ASP. NET folder" --> app_globalresources.
(2) Right-click the app_globalresources folder and choose "Add new item". Select "resource file" --> name it resource. resx.
(3) Open resource. resx and add any string resource.
(4) create a label control anywhere on the page. Use ide to view its properties. Click the small button after expressions to open the expression dialog box,
(5) Select resources. classkey as the expression type and enter the name of the global resource file (for example, the previously created resource ),
Enter the resource ID in resourcekey.
(6) In the design view, the IDE directly displays the content of the string resource on the label. You can switch to the source code to see the following code:
<Asp: Label id = "label1" runat = "server" text = "<% $ resources: resource, grtest %>"> </ASP: Label>
(7) At the same time, the text attribute of the label has a small blue image, indicating that the text is bound to the global resource.
(8) using a program to access global resources is easier than accessing local resources. The system automatically generates a corresponding strong type for all global resources.
The following code can directly read string resources in resource. resx:
String S = resources. Resource. grtest;
Response. Write (s );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.