有人能指出我对<%:?的定义吗?

时间:2011-08-13 16:45:02

标签: asp.net-mvc

我有这个,得到了“你好”,

<p> Howdy, <% Model.ToString(); %> </p>

我把它改成了

<p> Howdy, <%: Model.ToString() %> </p>

得到了“你好,克里斯”。 (这是我的预期。)我发现有几个页面列出了不同类型的内联表达式,但我找到的那些都没有列出带结肠的那个,并且google搜索“&lt;%:”似乎没有找到什么;)。

非常感谢

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

<% string name = "<strong>basilard99</strong>"; %>
Welcome <% name; %>!

呈现Welcome !

Welcome <% Response.Write(name); %>!
Welcome <%= name %>! <!-- Same thing -->

呈现Welcome <strong>basilard99</strong>!

Welcome <% Response.Write(Server.HtmlEncode(name)); %>!
Welcome <%: name %> <!-- Same thing -->

呈现Welcome &lt;strong&gt;basilard99&lt;/strong&gt;!

答案 2 :(得分:0)