asp.net inline tags


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <% ... %> The most basic inline tag, basically runs normal code:
  2.  
  3. <% if (User.IsInRole("admin")) { %> You can see this <% } else { %> You are no admin fool! <%} %>
  4. http://msdn2.microsoft.com/en-us/library/ms178135(vs.80).aspx
  5.  
  6. <%= ... %> Used for small chunks of information, usually from objects and single pieces of information like a single string or int variable:
  7.  
  8. The Date is now <%= DateTime.Now.ToShortDateString() %> The value of string1 is <%= string1 %> http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx
  9.  
  10. note: <%= is the equivalent of Response.Write() - Courtesy of Adam from the US,thanks!
  11.  
  12. <%# .. %> Used for Binding Expressions; such as Eval and Bind, most often found in data controls like GridView, Repeater, etc.:
  13.  
  14. <asp:Repeater ID="rptMeetings" DataSourceID="meetings" runat="server"> <ItemTemplate> <%# Eval("MeetingName") %> </ItemTemplate> </asp:Repeater>
  15.  
  16. http://msdn2.microsoft.com/en-us/library/ms178366.aspx
  17.  
  18. <%$ ... %> Used for expressions, not code; often seen with DataSources:
  19.  
  20. <asp:SqlDataSource ID="party" runat="server" ConnectionString="<%$ ConnectionStrings:letsParty %>" SelectCommand="SELECT * FROM table" /> http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx
  21.  
  22. <%@ ... %> This is for directive syntax; basically the stuff you see at the top your your aspx pages like control registration and page declaration:
  23.  
  24. <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> <%@ Register TagPrefix="wp" Namespace="CustomWebParts" %>
  25. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx
  26.  
  27.  
  28.  
  29.  
  30.  
  31. <% ... %> This is a server side comment, stuff you don't want anyone without code access to see:
  32.  
  33. <asp:Label ID="lblAwesome" runat="server" /> <% sometimes end users make me angry %> <asp:LinkButton ID="lbEdit" Text="Edit" OnClick="Edit_Click" runat="server" /> http://msdn2.microsoft.com/en-us/library/4acf8afk.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.