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

  • 相关阅读:
    MArkdown使用转
    吴恩达deep learning笔记。
    TCP状态转换图
    TCP关闭的四次握手
    SYN的中发送若干的TCP选项
    Ubuntu系统中切换root用户的命令,总忘了sudo
    logistic regression recap
    二分分类中的logistic回归(regression)
    UNIX下的网络族分类,IPv4和IPv6协议族
    11.8模拟赛
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/5096543.html
Copyright © 2020-2023  润新知