ASP Tutorial: Learning ASP Commands
1. Output instructions
The ASP output command <% =expression %> displays the value of the expression. This output command is equivalent to using Response.Write to display information. For example, the output expression <% =sport %> sends text climbing (the current value of the variable) to the browser.
2. Processing instructions
The ASP processing directive <% @ keyword %> sends information to IIS about how to process the .asp file (note that there must be a space between @ and keyword). In IIS 4.0, Active Server Pages (ASP) supports the following five @ directives.
@CODEPAGE
@ENABLESESSIONSTATE
@LANGUAGE
@LCID
@TRANSACTION
1.@ CODEPAGE instruction
You can use the @CODEPAGE directive to set the code page for .asp files. A code page is a character set that includes numbers, punctuation, and other characters. Different languages and sites use different code pages. For example, ANSI code page 1252 is used by US English and most European languages, while OEM code page 932 is used by Japanese Kanji.
A code page can be represented as a mapping table of characters to single-byte values or multi-byte values. Many code pages share the ASCII character set between 0x00-0x7F.
The code page set by the @CODEPAGE directive can be ignored via the Session.CodePage property. However, the results of this only apply to scripts run in session scope.
grammar
<%@ CODEPAGE=codepage%>
parameter
codepage
An unsigned integer representing the valid code page of the system on which the ASP script engine is running.
See
Session.CodePage
2.@ENABLESESSIONSTATE directive
Web session tracking can be turned off using the @ENABLESESSIONSTATE directive. Session tracking maintains a set of request information issued by a single client. If your web pages do not rely on session information, turning off session tracking can reduce the time IIS spends processing scripts.
grammar
<%@ ENABLESESSIONSSTATE=True|False %>
Comment
For more information about session tracking, see Managing Session State
3.@LANGUAGE directive
You can use the @LANGUAGE directive to set the language used to interpret commands in a script. You can set your scripting language to any of the scripting engines installed in IIS. The default is VBscript, so if you do not include @LANGUAGE in your script, the script will be interpreted by the VBscript engine.
grammar
<%@ LANGUAGE=scriptengine %>
parameter
scriptengine
A scripting engine that compiles scripts. IIS comes with two scripting engines, VBscript and Jscript.
Comment
The default scripting language can be changed using the AspscriptLanguage property of the IIS Admin object. You can apply this property to a Web service, Web server, virtual directory, or Web directory. For more information, see IIS Admin Object.
4.@LCID command
You can use the @LCID directive to set the locale identification (LCID) for a script. The data type of LCID is DWORD, the low word is the language identifier, and the high word is reserved. The LCID identifier is represented by an internationally standardized numerical abbreviation. The LCID uniquely identifies the installed system components required to define the site. There are two predefined LCID values, LOCALE_SYSTEM_DEFAULT is the system default site and LOCALE_USER_DEFAULT is the current user site.
grammar
<%@ LCID=localeidentifier %>
parameter
localeidentifer
Effective site identification.
See
Session.LCID
5.@TRANSACTION directive
You can use the @TRANSACTION directive to indicate that the script should be treated as a transaction. If the script is processed as a transaction, Microsoft Transaction Server (MTS) will create a transaction to coordinate resource updates.
grammar
<%@ TRANSACTION=value %>
parameter
value
A string indicating the type of transaction support, possible values are:
value meaning
Required script will initialize a transaction.
The Requires_New script will initialize a transaction.
Supported scripts will not initialize a transaction.
Not_Supported The script will not initialize a transaction.
Remark:
If the script contains a @TRANSACTION directive, it must be the first line in the .asp file, otherwise an error will occur. This directive must be added to each page that is to be run under a transaction. When the script processing is completed, the current transaction ends.