ASP.NET Server tags

I feel participating in technical forums is a good way to quiz one’s knowledge. I ran into a nice posting about ASP.NET server tags on ASP.NET Forums recently. Here is a quick reference of all the ASP.NET server tags with relevant links to MSDN:

  • <% %> - Represents an embedded code block that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class.
  • <%= %> - Short cut for Response.Write statement.
  • <%# %> - Used with data-binding expressions
  • <%$ %> - The dollar sign ($) indicates to ASP.NET that an expression follows. The expression prefix (<%$ expressionPrefix: expressionValue %> ) defines the type of expression, such as AppSettings, ConnectionStrings, or Resources. Following the colon (:) is the actual expression value that ASP.NET will resolve.
  • <%-- --%> - Used for Server-Side Comments.
  • <%@ %> - Represents a directive block.

The ASP.NET page framework supports the following directives:

  1. @ Page
  2. @ Control
  3. @ Import
  4. @ Implements
  5. @ Register
  6. @ Assembly
  7. @ Master
  8. @ WebHandler
  9. @ PreviousPageType
  10. @ MasterType
  11. @ OutputCache
  12. @ Reference

Related reading:
ServerTagsRegex Class - Provides a regular expression to parse ASP.NET server tags.

Comments