Scott Weinstein
Scott Weinstein

Reputation: 19117

Method equivalent of <%= expression %> in asp.net?

Total noob question here, but not finding the answer via search.

What is the method equivalant of <%= expression %>?

I'm looking to replace this:

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

with:

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

Upvotes: 1

Views: 173

Answers (5)

TrustyCoder
TrustyCoder

Reputation: 4789

I guess good old Response.Write would do the trick.

Upvotes: 10

egrunin
egrunin

Reputation: 25073

<%=var%> was and is simply shorthand for Response.Write(var). Under the hood they're equivalent.

Upvotes: 0

Pat Hermens
Pat Hermens

Reputation: 904

I often use the equivalent of the following:

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

or you could just use "Response.Write" like SLaks answer to make it easier to follow.

Upvotes: 0

Andrew
Andrew

Reputation: 8674

It was response Response.Write("...") in asp, and it looks to the be he same in asp.net.

Upvotes: 0

SLaks
SLaks

Reputation: 887767

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

Upvotes: 2

Related Questions