This section describes 3 ways to use VBScript codes in ASP pages: in-line statement, in-line expression, and statement block.
There are three ways to use VBScript in ASP pages:
1. In-line VBScript statements: The VBScript statements must be enclosed in
the special in-line script tag: <% %>. The enclosed statements will be executed
by the server, and the output of response.write() calls will be merged in-line
with the surrounding static HTML text. In-line VBScript statements require a language declaration
statement to define explicitly VBScript as the server side scripting language,
if you are not sure what is the default language defined on the Web server.
2. In-line VBScript expression: The VBScript expression must be enclosed in
the special in-line script tag: <% %> with a leading "=" sign. The enclosed
expression will be evaluated, and the resulting value will be converted into a
string and merged in-line with the surrounding static HTML text. In-line VBScript
expression also require a language declaration
statement to define explicitly VBScript as the server side scripting language,
if you are not sure what is the default language defined on the Web server.
3. Script block of VBScript statements: The VBScript statements must be
enclosed by the starting script block tag <script> and the ending tag </script>.
Two attributes are required on the script tag: "language" and "runat".
Please note that the script block VBScript statements will be executed by the server.
But the output of response.write() calls will not be merged in-line with the
surrounding static HTML text. It will be:
Inserted at the beginning of the HTTP response before any static HTML text,
if the server's default scripting language is not VBScript.
Appended at the end of the HTTP response after any static HTML text,
if the server's default scripting language is VBScript.
This rule was a big surprise to me.
I had to post a message to microsoft.public.inetsdk.programming.scripting.vbscript,
and got confirmed from Microsoft. See the article
Using VBScript and JScript on a Web Page.