This question already has an answer here:
- ASP.NET “special” tags 5 answers
Does anyone know the meaning of the following 4 code snipets (or shortcuts, i don't know how to call them) in Visual Studio:
<%= variable %>
<%# variable %>
<%: variable %>
<%$ variable %>
I know the first one inserts a value into the page and the second one is used for data binding.
Are there any other similar shortcuts?
The first one,
<%= %>
is called an inline expression, or a code render block. (http://msdn.microsoft.com/en-us/library/k6xeyd4z(v=vs.100).aspx)The second one,
<%# %>
is called a data binding expression. (http://msdn.microsoft.com/en-us/library/bda9bbfx(v=vs.100).aspx)The third one,
<%: %>
provides a way to automatically HTML encode the output of the code. I'm not sure what's it's called though so can't find you a documentation page on it, however there is a post on Scott Guthrie's blog: http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspxThe fourth one,
<%$ %>
is called expression builder syntax. (http://msdn.microsoft.com/en-us/library/d5bd1tad(v=vs.100).aspx)