Difference Between <%: and <%= [duplicate]
Possible Duplicate:
ASP.NET “special” tags
I hope this isn't too much of a newbie question. I seem to always use the correct syntax, but I don't really understand why I'm using the <%: and <%= in ASP.NET, and I was hoping someone could clarify for me. I found this article which explains <%= and <%#, but wasn't able to find anything i开发者_如何学运维n Google on <%:.
Examples of where I have used the various syntax:
<div>
<%: Html.LabelFor(model => model.Type) %>
<%: Html.TextBoxFor(model => model.Type)%>
</div>
and
<div id="header-menu">
<ul>
<li><%= Html.ActionLink("Home", "", "Home" )%></li>
</ul>
</div>
Thanks for any clarification.
Possible Answer (per ChrisF): ASP.NET "special" tags
<%: "some string" %>
is equal to:
<%= Html.Encode("some string") %>
<%:
is a new way to automatically HTML encode your data. Article from Haacked on it. New to .NET 4.0.
精彩评论