开发者

Difference Between <%: and <%= [duplicate]

开发者 https://www.devze.com 2023-01-14 04:21 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: ASP.NET “special” tags
This question already has answers here: Closed 12 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消