In ASP.NET MVC 2 <%:
tag was introduced to replace <%=
for Html helpers. But what does it mean and what is the difference to the previous one? When shall I use <%=
and when <%:
?
Thank you
In ASP.NET 4 the <%: xyz %>
syntax will do the same thing as <%= Server.HtmlEncode(xyz) %>
did in previous versions. It is simply a shortcut because it is used so often.
As Richard says below, it can also determine if a string does not need to be encoded based on whether or not it implements the IHtmlString
interface.
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