Thursday, February 9, 2012

ASP.NET Inline Tags

ASP.NET Inline Tags

There are six type of asp.net Inline Tags.


1. Most basic Inline Tag:
<%..........................%> runs normal code
 <% for(int i = 0; i < 12; i++) %>
       <% { Response.Write("<br>" + i.ToString()); }%>



2. Single Pieces of Info:
<%=...........................%>
Hello <%= name %>!

3. Server side comment - must have access to the code to see
<%--...............................--%>
<%--That's all folks--%>


4. Binding Expressions, such as Eval and Bind, most often found in data controls like GridView, Repeater, etc.:

<%#.............................%>

<table>
    <tr>
      <td align=right>
        <b>Employee ID:</b>
      </td>
      <td>
        <%# Eval("EmployeeID") %>
      </td>
    </tr>
    <tr>
      <td align=right>
        <b>First Name:</b>
      </td>
      <td>
        <asp:TextBox ID="EditFirstNameTextBox" RunAt="Server"
          Text='<%# Bind("FirstName") %>' />
      </td>
    </tr>
</table>



6. Expressions (not code) often DataSources:

<%$......................................%>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server"
    SelectCommand="SELECT * FROM [Employees]"
    ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>">
</asp:SqlDataSource>



No comments:

Post a Comment