Reputation: 2283
I've tried to perform a search on the above query but probably due to the angle brackets, I didn't find anything on the matter.
Could anyone please explain what the differences are between <%=
, <%:
<%#
?
I seem to recall that <%#
is preferred over <%=
but I am not sure why.
Upvotes: 4
Views: 88
Reputation: 8595
<%= xxx %>
Inserts the text in xxx into the page at that location. (more info)
<%: xxx %>
Same as above except it html encodes the text for your convenience - (Except if xxx is an HtmlString which indicates it is already encoded)
<%# xxx %>
Same as the first one too except xxx is only evaluated when DataBind() is called on the form (not really applicable in MVC) (more info)
Martin
Upvotes: 3
Reputation: 1038710
The following article describes them pretty well.
<%=
: Rendering Code Syntax<%: %>
: HTML encoded renedring (same usage as <%=
)<%# %>
: Data Binding Syntax - works with server side controls in classic WebForms applications, inapplicable in MVCUpvotes: 3