0

Not a difficult question but i can't seem to find a decent answer to it:

inline server code in client page, what are the usage/different of these:

<% %>
<%# %>
<%= %>

are there any more?

Eran Meir
  • 133
  • 2
  • 12

3 Answers3

1
<%    %>

Is used for executing arbitrary blocks of code on the server. Usually some type of control statement is place inside of them.

<%= %>

Writes content out to the response stream, similar to Response.Write().

Making something like (below) possible.

<table>
<%
    for (int i = 0; i < n; i++)
        %><tr><td><%= i %></td></tr><%
%>
</table>
whoisj
  • 398
  • 1
  • 2
  • 10
1

The <% %> tag is used for code blocks. The tag doesn't output anything in itself. Example:

<% int answer = 42; %>

The <%# %> tag is used for data binding.

The <%= %> tag is used for value output. The tag evaluates the expression and the result is written to the page. Example:

<%= answer %>

There is also the <%: %> tag, which is the same as the <%= %> tag except that the output is HTML encoded.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • Why the downvote? If you don't explain what it is that you think is wrong, it can't improve the answer. – Guffa Apr 28 '14 at 19:05
0

<%$ %> is used for Resources.

MateusBello
  • 376
  • 3
  • 8