zoukankan      html  css  js  c++  java
  • 我的ASP.NET之旅(三):ASP.NET表达式<% ... %>语法种种

    <%-- Content of comments, or commented out server controls --%>
    是服务器端的注释,就是注释,可以用来注释服务器端控件
    <% inline code %>
    是内嵌服务器解释的代码块,就是直接执行内部的表达式
    <%= inline expression %>
    是内嵌服务器输出块,就是直接输出内部的表达式
    <%# data-binding expression %>是数据绑定表达式,你知道的。
    <%$ expressionPrefix: expressionValue %>
    ASP.NET表达式。最有用的地方是在控件的一些硬编码文本处用资源文件的内容来代替,还有比如指示数据源控件的connectionString。
    <%@  %>指示语法,每个aspx,ascx,ashx,master等页面顶部都有的。

    示例如下:

    页面代码:

            <asp:Label ID="Label1" runat="server" Text="<%#HelloWorld()%>"></asp:Label>
            <br />
            <% Label2.Text = "Hi"; %>
            <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
            <br />
            <%=SayHello()%>

     后台代码:

        public String HelloWorld()
        {
            return "HelloWorld";
        }
    
        public String SayHello()
        {
            return "Hello";
        }
    
    
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.DataBind();//数据绑定表达式依赖此语句!!!
        }
    
  • 相关阅读:
    SSDT
    SSDT
    Rootkit之SSDT hook(通过CR0)
    直接用编译器按ctrl+F5运行和双击运行结果不一样
    HDU 1754 I Hate It
    HDU 1166 敌兵布阵
    网易2017内推笔试题 合唱团
    CodeForces 1151F Sonya and Informatics
    CodeForces 1151E Number of Components
    洛谷 P1962 斐波那契数列
  • 原文地址:https://www.cnblogs.com/ceachy/p/AspDotNet_InlineCommands.html
Copyright © 2011-2022 走看看