Use of ASP. NET resource Files

Source: Internet
Author: User

Transform different languages with simple settings and references

1, the new resource file resource.resx,vs2005 automatically put it in the App_GlobalResources folder;

2, open the resource file, enter the common string, the file is a collection of some key/value, key used to do the reference of the identity, value is used to represent the value of the string; (you can see that Resource.resx is actually an XML file after saving)

3, in the system for reference:

  • CS File Reference: String strhint = Resources.Resource.key
  • Normal references in ASPX files (character display):<td><%=resources.resource.key%> </td>
  • Property value reference (do attribute value) in aspx file: <asp:requiredfieldvalidator id= "Rfvsnum" runat= "Server" errormessage= "<%$ Resources: Resource, key%> "controltovalidate=" Tbsnum "display=" dynamic "/>

Note: Resources is a namespace, resource is the class that operates resource files in. NET, and key is the one that you set in the resource file.

Use of ASP. NET resource Files

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.