16

I've seen many different types of server side code blocks in aspx but never a simple key for what each means. I know some of these but it's really hard to search for symbols in a search engine! Can you help me out?

<% %> 
<%-- --%> 
<%@ %>
<%= %>
<%: %>
<%$ %>
<%# %>
Michael
  • 1,849
  • 18
  • 38

1 Answers1

30

You can find a bit more information about some of them at "ASP.NET Page Syntax".

IT researcher
  • 3,274
  • 17
  • 79
  • 143
mdm
  • 12,480
  • 5
  • 34
  • 53
  • 1
    +1, excellent answer. Just linkify *Resource Value* and it will be perfect. – Darin Dimitrov Jun 15 '11 at 22:16
  • 1
    Quite annoying that my Google/MSDN-fu couldn't get the resource value one though! Can anyone offer a link? – mdm Jun 15 '11 at 22:18
  • 3
    @mdm, it's because it's not *Resource Value* :-) It's HTML encode and it is available only in ASP.NET 4.0. `<%$ %>` is more like resource value – Darin Dimitrov Jun 15 '11 at 22:19
  • that's useful! did I miss any? – Michael Jun 15 '11 at 22:21
  • @Darin Dimitrov: Right you are, it is getting late here -_- I've updated with a link to ScottGu's excellent blog post about it. – mdm Jun 15 '11 at 22:24
  • 1
    @mdm, it's getting late here as well :-) Once again very good compilation of links. – Darin Dimitrov Jun 15 '11 at 22:26
  • @Darin Dimitrov: Thank you :) @Michael: Hoping that is all of them, I've seen them all in the wild apart from that pesky *HTML Encode*, although I'm sure someone will comment if we have missed any. – mdm Jun 15 '11 at 22:28
  • Looks like you're missing one: <%#: -- binding expression, HTML encoded – Chris Hynes Feb 19 '14 at 22:57
  • The ASP.NET Page Syntax link went bad. Update to http://msdn.microsoft.com/en-us/library/vstudio/fy30at8h%28v=vs.100%29.aspx – Sam Rueby Jun 17 '14 at 15:51