I'm not even sure i'm calling this the right thing. I'm just starting to get into ASP.Net and of course i'm starting to see syntax like <% "Code here" %>. So far i've seen <%: %>, <%= %>, <%# %>. Of course google doesn't like these symbols for searching so searching for help is futile :). Maybe this type of syntax is back from classic ASP (which i never used)? I don't know if there are any others than what i listed. Does anyone have a good link or can write up a good explanation. I also think it used in XML literals for vb.net. I also think its associated with certain functions like the "Eval" function.
+2
A:
To be short,
<%# %>
is used for data binding (for example in aListView
where you want to specify how elements must be displayed on a page). Ifthis.Page.DataBind()
(or control-level binding) is not called, nothing will be displayed.<%= %>
is used to display any string.<% %>
on the other hand would let you to do any stuff you want, but you must useResponse.Write()
to output something.<%: %>
is a new feature in .NET Framework 4.0 which does the same thing as<%= %>
, but encodes output to be displayed as HTML.
This is called inline tags, so searching for "asp.net inline tag" may give you additional info.
MainMa
2010-09-01 02:09:28
thanks a bunch mainma....is there any others that i didn't list?
je5
2010-09-01 02:14:07
@je5: yes, there are: `<%-- --%>` comment syntax, `<%@ %>` directives and the very strange `<%$ %>` used for expressions.
MainMa
2010-09-01 02:19:08