Code Render Blocks
Code render blocks define inline code or inline expressions that execute when the page is rendered. There are two styles of code render blocks: inline code and inline expressions. Use inline code to define self-contained lines or blocks of code. Use inline expressions as a shortcut for calling the Write method.
<% inline code %> <%=inline expression %>
A compilation error occurs if you try to include the character sequence %> anywhere inside a code render block. That sequence can only be used to close the code render block. For example, the following code will cause an error:
<%@ page language="C#" %> <% Response.Write(" %>"); %>
<%@ page language="VB" %>
<%
Response.Write("%>)
%>
To work around this error, you can build a string containing the sequence of characters, as in the following code example:
![]() |
---|
Unlike Active Server Pages (ASP), in ASP.NET it is invalid to declare a function or subroutine within a code render block (between <% and %> tags). |