App_GlobalResources and App_LocalResources are used in ASP.

Source: Internet
Author: User

Learning without thinking is reckless, thinking without learning is dangerous, one small step per day, a big step in success

App_GlobalResources and App_LocalResources are used in ASP.

App_GlobalResources is a global resource folder that contains information that is needed for all pages. App_LocalResources is a local resource folder, which is primarily a string and information to be used for this page.

First, let's take a look at how to create and use global and local resources in VS, first open VS, create a new Web page item, then click the Web site project, then right-click, new Folder App_GlobalResources and App_LocalResources

Then in App_GlobalResources, right-click Add New Item,Default.aspx. resx

And then how do you use that resource? Watch the code in text

<form id="Form1"runat="Server"> <div> <%--<asp:label id="Label1"runat="Server"text="<%$ resources:age%>"></asp:Label>--%> <asp:literal id="Literal1"runat="Server"text="<%$ resources:default.aspx,name%>"/> <asp:literal id="Literal2"runat="Server"text="<%$ resources:default.aspx,age%>"/> </div> </form>

Creating a local resource is the same as creating a global resource, but creating a local resource is named with the page name of the page, such as Index.aspx, and the new resource in the local resource is index.aspx.resx.

How do I use local resources? There are two ways to use local resources. Look at the following code

<form id="Form1"runat="Server"> <div> <asp:literal id="Literal1"text="<%$ resources:titile%>"runat="Server"></asp:Literal> <asp:button id="btnsubmit"meta:resourcekey="btnsubmit"runat="Server"/> </div> </form>

The code is downloaded as follows

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.