Expressions

ASP.NET Inline Expressions


Web page by Kevin Harris of Homer IL

Please contact Kevin Harris of Homer IL concerning this web site

https://support.microsoft.com/en-us/kb/976112

  1. <% ... %> - Embedded Code Blocks. The code in the block can execute programming statements and call functions in the current page class. Used in classical ASP.

    1
    2
    3
    4
    5
    <ul>
      <% for (int i = 0; i < 10; i++) { %>
       <li> <%= i.ToString() %> </li>
      <% } %></ul>
    


    <% ... %> - Embedded Code Blocks

  2. <%= ... %> - Writes to the response stream. Same as <% Response.Write() %>

  3. <%: ... %> - Same as above, except is HTML encoded.

  4. <%@ ... %> - Directive Expression. Specifies settings that are used by the page or user control.

    1
    2
    <%@ Page Title="Login Page" Language="C#" MasterPageFile="~/Site.master"
        AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Namespace.Login" %>
    


    <%@ ... %> - Directive Expression.

  5. <%# ... %> - Data Binding Expression. Creates binding between a server control property and a data source.

    1
    2
    <a href="/documents/nyseslat/<%# Eval("Filename") %>"
       style="font-family: Helvetica; font-size: 12px;"><%# Eval("Filename").ToString() %></a>
    


    <%# ... %> - Data Binding Expression

  6. <%$ ... %> - Expression Builder. Sets values of control properties based on the information that is contained in an application's configuration resource files.

    1
     ProviderName="<%$ ConnectionStrings:My.ProviderName %>"
    


    <%$ ... %> - Expression Builder.

  7. <%-- ... %> - Server-Side Comments Blocks. Content between the opening and closing tags of the server-side comments block will not be processed on the server or rendered on the resulting page.

    1
    2
    3
    4
    5
    6
    <%-- Current Password is Required. --%>
    <asp:RequiredFieldValidator
      ID="rfCurrentPassword" runat="server"  ControlToValidate="CurrentPassword"
      CssClass="failureNotificationMedium" ErrorMessage="Current Password is required." 
      ToolTip="Current Password is required." ValidationGroup="vgChangeUserPassword">*
    </asp:RequiredFieldValidator>
    


    <%-- ... %> - Server-Side Comments Blocks