When should I use # and = in ASP.NET controls?

There are a couple of different ‘bee-stings’:

  • <%@ – page directive
  • <%$ – resource access
  • <%= – explicit output to page
  • <%# – data binding
  • <%-- – server side comment block

Also new in ASP.Net 4:

  • <%: – writes out to the page, but with HTML encoded

Also new in ASP.Net 4.5:

  • <%#: – HTML encoded data binding

Leave a Comment