Latest web development tutorials

ASP Quick Reference

ASP from W3CSchool quick reference. Print it out and put it into a pocket, ready to use.

Basic Grammar

ASP script by the <% and%> surrounded. Write output to the browser:

<% Response.write ( "Hello World!")%>
</ Body>
</ Html>

The default ASP language is VBScript. To use another scripting language, in the top of the ASP page insert a language specification:

<% @ Language = "javascript"%>


Forms and user input

Request.QueryString form for collecting method = "get" the value. From a form using the GET method of transmitting information to all users it is visible (appears in the browser address bar), and on the amount of information transmitted is limited.

Request.Form collection for use method = "post" in the form of value. Using the POST method of transmitting information from the form is not visible to the user, and there is no limit on the amount of information to send.

ASP Cookies

cookie used to identify the user. A cookie is a server on the user's computer to stay in a small file. Whenever the same computer via the browser requests a page, this computer will send a cookie.

Response.Cookies command is used to create a cookie:

Response.Cookies ( "firstname") = "Alex"
Response.Cookies ( "firstname"). Expires = "May 10,2002"

Note: Response.Cookies command must appear before the <html> tag!

"Request.Cookies" command is used to retrieve cookie values:

fname = Request.Cookies ( "firstname")
response.write ( "Firstname =" & fname)

reference materials

By using the #include directive, you can perform before ASP file on the server, the contents of another ASP file into the ASP file. #include directive is used to create functions, headers, footers, and other elements need to be repeated or used on several other pages.


<-! # Include virtual = "" ->
<-! # Include file = "" ->

Please use the virtual keyword to indicate a path beginning with a virtual directory. If a file named "" is located in the virtual directory / html, the following line of code inserts "" contents of the document:

<-! #include Virtual = "/ html /" ->

Use the file keyword to indicate a relative path. Relative path is the directory that contains references began. If you have a file in the html directory, and the "" html file is located in the head, the following line of code is inserted "" contents of the document in your file:

<-! #include File = "" ->

Please use the file keyword with the syntax (..) to refer to higher-level files in the directory.


Global.asa file is an optional file that can contain declarations are subject ASP applications every page accessed, variables and methods.

Note: Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file.

Global.asa file can contain only the following:

  • Application Events
  • Session Event
  • <Object> statement
  • TypeLibrary Statement
  • #include directive

Application and Session event

In Global.asa you can tell the application and session objects when the application / session beginning what to do, what to do when the end of the application / session. The code to accomplish this task is placed in the event handler.Note: Since we can not use the ASP script delimiters (<% and%>) insert scripts in the Global.asa file, we need to handle routine placed in the HTML <script> tag inside:

<Script language = "vbscript" runat = "server">
sub Application_OnStart
'Some code
end sub
sub Application_OnEnd
'Some code
end sub
sub Session_OnStart
'Some code
end sub
sub Session_OnEnd
'Some code
end sub
</ Script>

<object> statement

Can <object> tag to create objects with session or application scope in Global.asa file by using.NOTE: <object> tag should be in the <script> tag outside!


<Object runat = "server" scope = "scope" id = "id"
{Progid = "progID" | classid = "classID"}>
</ Object>

TypeLibrary Statement

TypeLibrary (type library) is a container comprising a corresponding COM object DLL files. By including a call to TypeLibrary in the Global.asa file, you can access the constants of the COM object, and the ASP code also better able to report errors. If your Web application relies on COM object data types declared in a type library, you can type libraries in Global.asa statement.


<-! METADATA TYPE = "TypeLib"
file = "filename"
uuid = "typelibraryuuid"
version = "versionnumber"
lcid = "localeid"

Session Object

Session object is used to store information about a user session (session), or change the user session (session) setting. Variable stores a single user's information is stored in the Session object, and are available for applications in all pages.


  • Contents - contains all added to the session through a script command entry.
  • StaticObjects - contains all use the HTML <object> tag is appended to the session object.
  • Contents.Remove(item / index) - remove an item from the Contents collection.
  • Contents.RemoveAll () - Remove all items from the Contents collection.


  • CodePage - specified character sets used when dynamic content.
  • LCID - is used to display dynamic content area identifier.
  • SessionID - Returns the session id
  • Timeout - Sets or returns the session timeout.


  • Abandon - revocation session object all objects.

Application Object

Work together to accomplish a task group ASP file called an application. Application object is used to put these files bundled together. All users share one Application object. Application objects there will be a lot of information in the application page uses (such as database connection information).


  • Contents - include all additional script commands to the application program.
  • StaticObjects - contains all use the HTML <object> tag is appended to the application object.
  • Contents.Remove - remove an item from the Contents collection.
  • Contents.RemoveAll - Remove all items from the Contents collection.


  • Lock - prevent users from modifying Application object properties.
  • Unlock - Allows users to modify Application object properties.

Response Object

Response objects for results from the server to the user to send the output.


  • Cookies (name) - set the value of the cookie. If the cookie does not exist, create a cookie, and sets the specified value.


  • Buffer - Specifies whether the output buffer. When output buffer is set, the server will prevent a response to the browser until all of the server scripts have been processed, or until the script calls the Flush or End method. If you want to set this property, it should be located in an ASP file <html> tag before.
  • CacheControl - whether to set a proxy server can cache the output generated by the ASP. If set to Public, then the proxy server will cache pages.
  • Charset(charset_name) - the name of the character set (such as "ISO8859-1") appended to the Response object content-type header.
  • ContentType - setting Response object HTTP content type (eg "text / html", "image / gif", "image / jpeg", "text / plain"). The default is "text / html".
  • Expires - Settings page in the browser cache time (minutes) before failure.
  • ExpiresAbsolute - set the date and time on a browser page cache invalidation.
  • IsClientConnected - Indicates whether the client is disconnected from the server.
  • Pics(pics_label) - PICS tag value is added to the response header.
  • Status - predetermined value returned by the server status line.


  • AddHeader(name, value) - Add a new HTTP response header and value to HTTP.
  • AppendToLogstring - the string to add to the server log entry (server log entry) end.
  • BinaryWrite(data_to_write) - write data without any character conversion case directly to the output.
  • Clear - Clear buffered output. Use this method to handle errors. If Response.Buffer not set to true, the method will produce a run-time error.
  • End - stops processing the script and returns the current result.
  • Flush - send buffered output immediately. If Response.Buffer not set to true, the method will produce a run-time error.
  • Redirect(url) - redirect the user to another URL.
  • Write(data_to_write) - write text to the user.

Request Object

When a browser requests to the server page, this behavior is called a request (request). Request object is used to obtain information from the user.


  • ClientCertificate - contains all field values ​​stored in the client certificate.
  • Cookies(name) - contains all the HTTP cookie value sent in the request.
  • Form(element_name) - contains all the forms using the post method to send the form (input) value.
  • QueryString(variable_name) - contains all the HTTP query string variable values.
  • ServerVariables(server_variable) - contains all the server variable values.


  • TotalBytes - Returns the total number of bytes in the body of the request sent by the client.


  • BinaryRead - retrieved as part sent from the client to the server post requested data.

Server Object

Server object is used to access properties and methods on the server.


  • ScriptTimeout - Sets or returns the maximum value in a script before it can terminate the running time (sec).


  • CreateObject(type_of_object) - you create an object instance.
  • Execute(path) - execute another ASP file from inside the ASP file. After the completion of the implementation of the ASP file is called, control returns to the previous ASP files.
  • GetLastError () - Returns the error has occurred can be described as a state ASPError object.
  • HTMLEncode(string) - a string of HTML coding applications.
  • MapPath(path) - the relative or virtual path is mapped to a physical path.
  • Transfer(path) - to send all status messages to another file for processing. After the transmission, control of the program does not return the original ASP file.
  • URLEncode(string) - Application URL string encoding rules.

Source: http: //