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:
<%@ page language="C#" %>
<%
String s = "%" + ">";
Response.Write(s);
%>
<%@ page language="VB" %>
<%
Dim s as String
s = "%" & ">"
Response.Write(s)
%>
Note: |
|---|
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).
|