What is the difference between <% %>
and <%= %>
in ASP.NET MVC? And when to use which?
What is the difference between <% %>
and <%= %>
in ASP.NET MVC? And when to use which?
See also this question. MVC hasn't changed how these bee-stings work, just how often they're used.
Basically:
<%
- execute code<%@
- page directive<%$
- resource access<%=
- explicit output to page<%#
- data binding<%--
- server side comment blockAlso new in ASP.Net 4:
<%:
- writes out to the page, but with HTML encoded