ASP.NET MVC: Code Nuggets

<% %>, <%= %>, and <%: %> have special meaning:

Code enclosed within <% %> will be executed
Code enclosed within <%= %> will be executed, and the result will be outputted to the page
Code enclosed within <%: %> will be executed, and the result will be outputted to the page, as well as being HTML encoded

If you’re on ASP.NET 4 or later, you’ll want to use the <%: %> syntax vs. the <%= %> syntax, as the result gets HTML encoded.

Leave a Reply

Your email address will not be published. Required fields are marked *