ASP Quick Reference
ASP Quick Reference from welookups. Print it, and overlay it in your pocket.
ASP contents are encompassed by <% and %>. To keep in touch with a few yield to a browser:
<% response.write("Hello World!") %>
The default language in ASP is VBScript. To utilize another scripting language, embed a language particular at the highest point of the ASP page:
Forms and User Input
Request.QueryString is utilized to gather esteems in a structure with method="get". Data sent from a structure with the GET strategy is obvious to everybody (it will be shown in the program's location bar) and has confines on the measure of data to send.
Request.Form is utilized to gather esteems in a structure with method="post". Data sent from a structure with the POST strategy is undetectable to other people and has no restrictions on the measure of data to send.
A treat is frequently used to distinguish a client. A treat is a little document that the server implants on the client's PC. Each time a similar PC asks for a page with a program, it will send the treat too.
The Response.Cookies direction is utilized to make cookies:
Note: The Response.Cookies direction must show up BEFORE the <html> tag!
The "Request.Cookies" direction is utilized to recover a treat value:
response.write("Firstname=" & fname)
You can embed the substance of one ASP record into another ASP document before the server executes it, with the #include mandate. The #include mandate is utilized to make capacities, headers, footers, or components that will be reused on various pages
<!- - #include virtual="somefile.inc"- - >
<!- - #include document ="somefile.inc"- - >
Use the virtual catchphrase to show a way starting with a virtual registry. On the off chance that a document named "header.inc" dwells in a virtual registry named /html, the accompanying line would embed the substance of "header.inc":
<!- - #include virtual ="/html/header.inc" - >
Use the record catchphrase to demonstrate a relative way. A relative way starts with the registry that contains the including document. On the off chance that you have a document in the html registry, and the document "header.inc" dwells in html\headers, the accompanying line would embed "header.inc" in your file:
<!- - #include record ="headers\header.inc" - >
Use the record catchphrase with the sentence structure (..\) to incorporate a document from a more elevated amount directory.
The Global.asa record is a discretionary document that can contain assertions of articles, factors, and strategies that can be gotten to by each page in an ASP application.
Note: The Global.asa document must be put away in the root registry of the ASP application, and every application can just have one Global.asa file.
The Global.asa record can contain just the following:
- Application occasions
- Session occasions
- <object> declarations
- TypeLibrary revelations
- the #include directive
Application and Session Events
In Global.asa you can guide the application and session objects at the point when the application/session begins and what to do when the application/session closes. The code for this is put in occasion handlers. Note: We don't utilize <% and %>, to embed contents in the Global.asa record, we need to put the subroutines inside the HTML <script> tag:
<script language="vbscript" runat="server">
' some code
' some code
' some code
' some code
It is likewise conceivable to make objects with session or application scope in Global.asa by utilizing the <object> tag. Note: The <object> tag ought to be outside the <script> tag!
<object runat="server" scope="scope" id="id"
A TypeLibrary is a holder for the substance of a DLL document comparing to a COM object. By including a call to the TypeLibrary in the Global.asa record, the constants of the COM article can be gotten to, and blunders can be better announced by the ASP code. On the off chance that your Web application depends on COM objects that have proclaimed information types in sort libraries, you can announce the sort libraries in Global.asa.
<!- - METADATA TYPE="TypeLib"
The Session Object
The Session object is utilized to store data about, or change settings for a client session. Factors put away in the Session object hold data about one single client, and are accessible to all pages in one application.
- Substance - Holds each thing added to the session with content commands
- StaticObjects - Holds each item added to the session with the <object> tag, and a given session
- Contents.Remove(item/index) - Deletes a thing from the Contents collection
- Contents.RemoveAll() - Deletes each thing from the Contents collection
- CodePage - Sets the code page that will be utilized to show dynamic content
- LCID - Sets the area identifier that will be utilized to show dynamic content
- SessionID - Returns the session id
- Timeout - Sets the timeout for the session
- Surrender - Kills each item in a session object
A gathering of ASP documents that cooperate to play out a few design is called an application. The Application object in ASP is utilized to tie these records together. All clients share one Application object. The Application object should hold data that will be utilized by numerous pages in the application (like database association information).
- Substance - Holds each thing added to the application with content commands
- StaticObjects - Holds each article added to the application with the <object> tag
- Contents.Remove - Deletes a thing from a collection
- Contents.RemoveAll - Deletes each thing from a collection
- Lock - Prevents a client from changing the application object properties
- Open - Allows a client to change the application object properties
The Response Object
The Response Object is utilized to send yield to the client from the server.
- Cookies(name) - Sets a treat esteem. In the event that the treat does not exist, it will be made, and take the esteem that is specified
- Buffer - Whether to cradle the yield or not. At the point when the yield is supported, the server will keep down the reaction until the majority of the server contents have been prepared, or until the content calls the Flush or End technique. In the event that this property is set, it ought to be before the <html> tag in the ASP file
- CacheControl - Sets whether intermediary servers can reserve the yield or not. At the point when set to Public, the yield can be reserved by an intermediary server
- Charset(charset_name) - Sets the name of the character set (like "ISO8859-1") to the substance type header
- ContentType - Sets the HTTP content sort (like "text/html", "image/gif", "image/jpeg", "text/plain"). Default is "text/html"
- Expires - Sets to what extent a page will be reserved on a program before it expires
- ExpiresAbsolute - Sets a date and time when a page stored on a program will expire
- IsClientConnected - Checks if the customer is as yet associated with the server
- Pics(pics_label) - Adds an incentive to the pics name reaction header
- Status - Specifies the estimation of the status line
- AddHeader(name, value) - Adds a HTML header with a predefined value
- AppendToLog string - Adds a string as far as possible of the server log entry
- BinaryWrite(data_to_write) - Writes the given data without any character-set conversion
- Clear - Clears the cushioned yield. Utilize this technique to deal with mistakes. On the off chance that Response.Buffer isn't set to genuine, this strategy will cause a run-time error
- End - Stops preparing the content, and return the current result
- Flush - Sends support