zoukankan      html  css  js  c++  java
  • 转asp.net中的App_GlobalResources和App_LocalResources使用

    asp.net中的App_GlobalResources和App_LocalResources使用

    App_GlobalResources是全局资源文件夹,主要存放一些所有页面都需要用到的信息。App_LocalResources是本地资源文件夹,主要存放的是该页面所要用到的字符串和信息。

    首先我们来看一下在VS中怎么创建和使用全局资源和本地资源,首先打开VS,新建一个网页项目,然后在单击该网站项目,然后单击右键,新建文件夹App_GlobalResources和App_LocalResources

    然后在App_GlobalResources,点击右键添加新项, Default.aspx .resx

    然后怎么使用该资源呢?注意看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>
    创建本地资源和创建全局资源是一样的,但是创建本地资源的名字是用该页的页面名来命名的,如index.aspx,则在本地资源中新建的资源为index.aspx.resx。

    如何使用本地资源呢?使用本地资源的方式有两种。看如下代码

    <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>

    http://www.tuicool.com/articles/MFBVRr

  • 相关阅读:
    微擎开发------day02
    微擎开发------day01
    Myisam 和 Innodb 区别
    Curl的简单使用步骤
    微信小程序之----获取设备信息
    微信小程序之 -----事件
    微信小程序之---- 数据处理
    微信小程序之----制作视频弹幕
    cocos2dx安卓客户端接入移动MM付费SDK
    Win7 / Win8 搭建配置【vs2010】、【cocos2dx环境】、【Android平台】
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/5096543.html
Copyright © 2011-2022 走看看