|
When developing your web pages, you can include HTML
and scripting code in the same file but you must distinguish them. While
HTML uses its own tags, to show the beginning of an Active Server Pages
script, you must type <%, which is called a delimiter. To show the
end of that section, you must type %>, which is also called a delimiter.
|
Here is an example:
<html>
<head>
<title>Exercise</title>
</head>
<body>
<% %>
</body>
</html>
most of the time, you will write each delimiter on its
own line. Here is an example;
<html>
<head>
<title>Exercise</title>
</head>
<body>
<%
%>
</body>
</html>
This technique is not a rule. Sometimes it simply makes your
code easier to ready. Everything between <% and %> is part of the script and is reserved
only for the script.
Although we created only one delimiting section, you can
create as many delimiting sections as you want. Here are examples:
<html>
<head>
<title>Exercise</title>
</head>
<body>
<% %>
<% %>
<% %>
</body>
</html>
Of course, you can create the sections where each delimiter
is on its own line:
<html>
<head>
<title>Exercise</title>
</head>
<body>
<% %>
<%
%>
<% %>
<%
%>
</body>
</html>
Between an opening delimiter <% and a closing
delimiter %>, you can add the necessary ASP code, which can consist of
ASP code, HTML code, and others. Before an opening delimiter <% or after a
closing delimiter %>, you can add HTML code as you want but no ASP code:
<html>
<head>
<title>Exercise</title>
</head>
<body>
HTML Code
<%
ASP Code, HTML Code, Scripting Code
%>
HTML Code
<%
ASP Code, HTML Code, Scripting Code
%>
HTML Code
<%
ASP Code, HTML Code, Scripting Code
%>
HTML Code
</body>
</html>