zoukankan      html  css  js  c++  java
  • asp.net的<% %>总结

          在asp.net应用程序中,在asp.net页面常用的<%@ %>、<%# %>、<%= %>。在全球化的项目中使用<%$ %>绑定资源项目,在asp.net mvc中使用<%: %>绑定ViewData。

          <%@ %>主要用于在web页面定义Page、引入控件、组件、设置Cache等:

    1:  <%@ Page %>
    2:  <%@ Assembly %>
    3:  <%@ Import %>
    4:  <%@ MasterType %>
    5:  <%@ OutputCache %>
    6:  <%@ PreviousPageType %>
    7:  <%@ Reference %>
    8:  <%@ Register %>

         <%# %>主要用来绑定后台数据到前台,一般在后台都需要有对应的DataBind()在执行绑定。

     1:  <asp:GridView ID="gvProducts" runat="server">
     2:            <Columns>
     3:               <asp:TemplateField>
     4:                    <ItemTemplate>
     5:                        <%# Eval("ProductName") %>
     6:                    </ItemTemplate>
     7:               </asp:TemplateField>
     8:            </Columns>
     9:      </asp:GridView>

          <%= %>主要用于在前台输入后台变量。

    1:   <%= Page.IsPostBack %>
    2:   <%= %> == <% Response.Write() %>

          <%$ %>用于在全球化解决方案中,指定前台页面对应的资源项。

    1:  <asp:Label ID="lblAmount" runat="server" Text="<%$ Resources:TestSiteResources, TotalAmount %>"></asp:Label>

          <%: %>在asp.net mvc项目中绑定ViewData。

    1:  <%: %> = <%= Server.HtmlEncode(content) %> *必要条件.NET 4*
  • 相关阅读:
    游戏玩家 专有名词 All In One
    Xbox 无线控制器详细使用说明图解教程 All In One
    leetcode online interview All In One
    vcharts custom tooltip All In One
    kaggle All In One
    elpopover ::after style overwrite bug All In One
    webpack 插件 All In One
    js inplace algorithm All In One
    leetcode 面试必刷的算法 100 题 All In One
    vcharts no data All In One
  • 原文地址:https://www.cnblogs.com/valu/p/1782087.html
Copyright © 2011-2022 走看看