等效于<%= expression%>的方法在asp.net?

时间:2010-05-06 17:15:43

标签: asp.net-mvc

这里的总菜鸟问题,但没有通过搜索找到答案。

<%= expression%>?

的等效方法是什么?

我想替换这个:

<%
 foreach (var intem in IE) {
%>
  <%= Ajax.ActionLink(item,...) %>
<% } %>

使用:

<%
 foreach (var intem in IE) {
    SomeOutputCall(Ajax.ActionLink(item,...));
} 
%>

5 个答案:

答案 0 :(得分:10)

我想好老Response.Write可以做到这一点。

答案 1 :(得分:2)

Response.Write(Ajax.ActionLink(item,...));

答案 2 :(得分:0)

在asp中响应Response.Write(“...”),它看起来与asp.net中的相同。

答案 3 :(得分:0)

我经常使用以下内容:

<%
 foreach (var intem in IE) {
    HttpContext.Current.Response.Write(Ajax.ActionLink(item,...));
} 
%>

或者您可以像SLaks一样使用“Response.Write”,以便更容易理解。

答案 4 :(得分:0)

<%=var%>过去只是Response.Write(var)的缩写。在引擎盖下它们是相同的。