是&LT;%:和&lt;%=一回事embbed code(如pression)块 [英] Are <%: and <%= the same thing as embbed code (expression) blocks
问题描述
说完刚开始MVC 2我注意到,在其首发的模板,他们使用
Having just started with MVC 2 I notice that in their starter template they use
<%: Html.ActionLink("Home", "Index", "Home")%>
和我很肯定,在MVC 1是
and I was sure that in MVC 1 it was
<%= Html.ActionLink("Home", "Index", "Home")%>
他们是同样的事情?如果是这样,为什么从等号结肠癌的变化。
Are they the same thing? If so, why the change from equal sign to colon.
推荐答案
冒号语法意味着你将HTML带$ C $自动CD:<一href=\"http://haacked.com/archive/2009/09/25/html-encoding-$c$c-nuggets.aspx\">http://haacked.com/archive/2009/09/25/html-encoding-$c$c-nuggets.aspx
the colon syntax means you'll be html encoded automatically: http://haacked.com/archive/2009/09/25/html-encoding-code-nuggets.aspx
他们不能只是HTML EN code所有现有的&LT;%=
块,因为事情已经正确连接codeD(这是希望大部分项目在那里)会看起来很奇怪。
They couldn't just html encode all the existing <%=
blocks, because things that are already properly encoded (which is hopefully most of the projects out there) would look strange.
这篇关于是&LT;%:和&lt;%=一回事embbed code(如pression)块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!