I'm new to ASP.NET MVC. I've seen both <%= ... %> and <%: ... %>. I'm familiar with the first from classic ASP days, but not the latter. What is the difference between the two?
<%= %>
- equivalent to response.write in classic ASP.
<% %>
- represents a code block, if, then else, for each, etc.
<%: %>
- this is a shortcut new to .NET 4, this represents <%= html.encode(item) %>
Link to video explaining the shortcut (it's a short clip):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With