There are four kinds of tags demarcating ASP server-side script on an ASP page. All other code on the page is on the HTML page itself, ie is client-side, and is visible client-side.
<%@ ... %>. ASP Processing Directives are used to enclose information about the script authoring environment. In Classic ASP, this is commonly used to set the server-side language. In ASP.NET, this is commonly used to set up the CodeFile for code-behind.
<% ... %>. Used to enclose standard ASP server-side script. Script comments are not passed on to the browser but HTML comments are.
<%= ... %>. ASP Output Directives are used to enclose output directive information (equivalent to Response.Write). Script comments are not allowed within ASP output tags.
<script runat="server" language="scriptingLanguage"> ... </script>or
<script runat="server" language="scriptingLanguage" src="SourceFile"></script>. These kind of tags can only contain sub-routines, not free standing code. These are generally run before code in
<% ... %>. Good for specifying script language on a per-block basis.
Note that the top of the example is typical for many ASP pages.
The ASP processing directive which denotes the server side scripting language used (EG:
<%@ language="VBScript" %>) is usually the first real line of an ASP page. It is common practice to have it and other common code put at the top of a page via an Server Side Include (SSI) directive (EG:
<!-- #include file="ssVBS.asp" --> or
<!-- #include virtual="/ssVBS.asp" -->: The former is virtual while the latter is relative.). Note that if you want to have the server side code properly color coded by the Visual InterDev IDE, and your server side scripting language is not VBScript, then you will want to not include the ASP processing directive included in the SSI directive, i.e. the top of each page would be like this:
The file indicated by an SSI cannot be a variable since includes are processed and inserted before the server process the ASP script. EGs:
<% 'This will not work %> <!-- #include virtual=\includes\file<%= x %>.asp -->
<% 'This will work %> <% If x = 1 Then %> <!-- #include virtual=\includes\file1.asp --> <% Else %> <!-- #include virtual=\includes\file2.asp --> <% End If %>
<% 'This will also work If x = 1 Then Response.Write("file1.asp") Else Response.Write("file2.asp") End If %>