ASP.NET inline expressions

<% … %> Embedded Code Blocks in ASP.NET Web Pages

Server tags cannot contain <% … %> constructs
The code in the block can execute programming statements and call functions in the current page class during the page-rendering phase.

<%@ Page Language="VB" %>
<html>
<body>
 <form id="form1" runat="server">
 <% For i As Integer = 16 To 24 Step 2%>
 <div style="font-size: <% Response.Write(i)%>">
 Hello World<br />
 </div>
 <% Next%>
 </form>
</body>
</html>

<%= … %> displaying expression

equivalent of the embedded code block that contains only the Response.Write(…) statement. This is the simplest way to display information such as a single string, an int variable, or a constant.
displaying expression cannot be used in the attributes of server controls. This is because the .NET Framework directly compiles the whole expression instead of the displaying content as the value to the attribute.

<%@ Page Language="VB" %>
<html>
<body>
 <form id="form1" runat="server">
 <%=DateTime.Now.ToString() %>
 </form>
</body>
</html>

<%@ … %> directive expression

<%# … %> data-binding expression

The data-binding expression creates binding between a server control property and a data source when the control’s DataBind method of this server control is called on the page.

<%$ … %> expression builder

More information regarding to ASP.NET expression can be found ASP.NET Expressions Overview  and ExpressionBuilder Class.

<%– … — %> server-side comments block

<!– #include file|virtual=”filename” –> Server-Side Include Directive Syntax

More information:

Introduction to ASP.NET inline expressions in the .NET Framework

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s