ASP Examples
- Previous Page ASP Course Summary
- Next Page ASP Quiz
Basics:
- Writing text with ASP
- If generating text using ASP.
- Add HTML to the text
- If generating both HTML tags and plain text.
Variable:
- Declare a variable
- Variables are used to store information. This example demonstrates how to declare a variable, assign a value to it, and use this variable in the program.
- Declare an array
- Arrays are used to store a series of related data items. This example demonstrates how to declare an array to store names.
- Loop to generate HTML headings
- How to loop to generate 6 different HTML headings.
- Creating time-based greetings using Vbscript
- This example will display different messages to the user based on the server time.
- Creating time-based greetings using JavaScript
- This example is the same as the previous one, just with different syntax.
Program:
- Calling a subroutine using VBScript
- How to call a subroutine written in VBScript from ASP.
- Calling a subroutine using JavaScript
- How to call a subroutine written in JavaScript from ASP.
- Calling subroutines using VBScript and JavaScript
- How to call subroutines written in VBScript and JavaScript in an ASP file.
Form:
- Form using method="get"
- How to interact with users using the Request.QueryString command.
- Form using method="post"
- How to interact with users using the Request.Form command.
- Form using radio buttons
- How to interact with the user using radio buttons through Request.Form.
Cookie:
- Welcome cookie
- How to create a welcome cookie.
Response object:
- Write text using ASP
- Use ASP to write text
- Format text with HTML tags in ASP
- This example demonstrates how to combine text with HTML tags using ASP.
- Redirect the user to a different URL
- This example demonstrates how to redirect the user to a different URL.
- Display random links
- This example demonstrates a hyperlink that will display one of the two links each time the page is loaded.
- Control cache
- This example demonstrates how to control the cache.
- Clear cache
- This example demonstrates how to clear the cache.
- Terminate the script during processing and return the result
- This example demonstrates how to interrupt the execution of a script during the processing process.
- Set how many minutes to cache the page in the browser before it expires
- This example demonstrates how to specify the cache time of the page in the browser before it expires.
- Set the expiration date or time of the page cache in the browser
- This example demonstrates how to specify the cache time, date, or time of the page in the browser.
- Check if the user is still connected to the server
- This example demonstrates how to check if the user has disconnected from the server.
- Set content type
- This example demonstrates how to specify the type of content.
- Set character set
- This example demonstrates how to specify the name of the character set.
QueryString collection instance
- Sending query information when a user clicks a link
- This example demonstrates how to send additional query information in a link to a page and retrieve this information on the target page (in this example, the same page).
- A simple application of the QueryString collection
- This example demonstrates how the QueryString collection retrieves values from the form. This form uses the GET method, which means the information sent is visible to the user (in the address). The GET method also limits the amount of information sent.
- How to use information sent from the form
- This example demonstrates how to use values retrieved from the form. We will use the QueryString collection. This form uses the GET method.
- More information from the form
- This example demonstrates what the QueryString will contain if the input field contains several identical names. It will show how to split these identical names. It will also show how to use the count keyword to count the 'name' attribute. This form uses the GET method.
Form collection instance
- A simple application of the Form collection
- This example demonstrates how the Form collection retrieves values from a form. This form uses the POST method, which means the information sent is invisible to the user and there is no limit to the amount of information that can be sent (large amounts of information can be sent).
- How to use information from the form
- This example demonstrates how to use the information retrieved from the form. We used the Form collection. The form uses the POST method.
- More information from the form
- This example demonstrates what information the Form collection would contain if several input fields used the same name. It will show how to split these identical names. It will also show how to use the count keyword to count the "name" attribute. This form uses the POST method.
- Form with radio buttons
- This example demonstrates how to interact with the user using the Form collection through radio buttons. This form uses the POST method.
- Form with check boxes
- This example demonstrates how to interact with the user using the Form collection through check boxes. This form uses the POST method.
Other examples
- Obtain user information
- How to find out the browser type, IP address, and other information of the visitor
- Obtain server variables
- This example demonstrates how to use the ServerVariables collection to obtain the browser type, IP address, and other information of the visitor.
- Create welcome cookie
- This example demonstrates how to create a welcome cookie using the Cookies collection.
- Detect the total number of bytes sent by the user
- This example demonstrates how to use the TotalBytes property to get the total number of bytes sent by the user in the Request object.
Session object
- Set and return LCID
- This example demonstrates the "LCID" property. This property sets and returns an integer that indicates a location or region. Similar to dates, times, and currencies, content should be displayed according to the location or region.
- Return SessionID
- This example demonstrates the "SessionID" property. This property returns a unique id for each user. This id is generated by the server.
- Session timeout
- This example demonstrates the "Timeout" property. This example sets and returns the session timeout time (in minutes).
Server object
- When was this file last modified?
- Detect the last update time of the file.
- Open and read a text file
- This example opens the file "Textfile.txt" for reading.
- Self-made click counter
- This example reads a number from a file, adds 1 to it, and then writes this number back to the file.
FileSystemObject object
- Does the specified file exist?
- This example demonstrates how to first create a FileSystemObject object, and then use the FileExists method to check if a file exists.
- Does the specified folder exist?
- This example demonstrates how to use the FolderExists method to check if a folder exists.
- Does the specified drive exist?
- This example demonstrates how to use the DriveExists method to detect whether a specified drive exists.
- Obtain the name of a specified drive
- This example demonstrates how to use the GetDriveName method to obtain the name of a specified drive.
- Obtain the name of the parent folder of a specified path
- This example demonstrates how to use the GetParentFolderName method to obtain the name of the parent folder of a specified path.
- Obtain the folder extension
- This example demonstrates how to use the GetExtensionName method to obtain the file extension of the last component in the specified path.
- Obtain the file name
- This example demonstrates how to use the GetFileName method to obtain the file name of the last component in the specified path.
- Obtain the base name of the file or folder
- This example demonstrates how to use the GetBaseName method to return the base name of the file or folder in the specified path.
TextStream object
- Read the file
- This example demonstrates how to use the OpenTextFile method of FileSystemObject to create a TextStream object. The ReadAll method of TextStream object will obtain the content from the opened text file.
- Read a part of the text file
- This example demonstrates how to read only a part of the content of a text stream file.
- Read a line from the text file
- This example demonstrates how to read a line of content from a text stream file.
- Read all lines of the text file
- This example demonstrates how to read all lines from the text stream file.
- Skip a part of the text file
- This example demonstrates how to skip a specified number of characters when reading a text stream file.
- Skip a line in the text file
- This example demonstrates how to skip a line when reading a text stream file.
- Return the line number
- This example demonstrates how to return the current line number in the text stream file.
- Obtain the column number
- This example demonstrates how to obtain the column number of the current character in the file.
Drive object
- Obtain the number of available space of the specified drive
- This example demonstrates how to first create a FileSystemObject object, and then use the AvailableSpace property to obtain the available space of the specified drive.
- Obtain the remaining space capacity of the specified drive
- This example demonstrates how to use the FreeSpace property to obtain the remaining space of the specified drive.
- Obtain the total capacity of the specified drive
- This example demonstrates how to use the TotalSize property to obtain the total capacity of the specified drive.
- Obtain the drive letter of the specified drive
- This example demonstrates how to use the DriveLetter property to obtain the drive letter of the specified drive.
- Obtain the drive type of the specified drive
- This example demonstrates how to use the DriveType property to obtain the drive type of the specified drive.
- Obtain the file system information of the specified drive
- This example demonstrates how to use FileSystem to obtain the file system type of the specified drive.
- Is the drive ready?
- This example demonstrates how to use the IsReady property to check if the specified drive is ready.
- Obtain the path of the specified drive
- This example demonstrates how to use the Path property to obtain the path of the specified drive.
- Obtain the root folder of the specified drive
- This example demonstrates how to use the RootFolder property to obtain the root folder of the specified drive.
- Obtain the serial number of the specified drive
- This example demonstrates how to use the Serialnumber property to obtain the serial number of the specified drive.
File Object
- When was the file created?
- This example demonstrates how to first create a FileSystemObject object, then use the DateCreated property of the File object to obtain the date and time the specified file was created.
- When was this file modified?
- This example demonstrates how to use the DateLastModified property to obtain the date and time the specified file was last modified.
- When was this file accessed?
- This example demonstrates how to use the DateLastAccessed property to obtain the date and time the specified file was last accessed.
- Return the properties of a specified file
- This example demonstrates how to use Attributes to return the properties of a specified file.
Dictionary Object
- Does the specified key exist?
- This example demonstrates how to first create a Dictionary object, then use the Exists method to check if the specified key exists.
- Return an array of all items
- This example demonstrates how to use the Items method to return an array of all items.
- Return an array of all keys
- This example demonstrates how to use the Keys method to return an array of all keys.
- Return the value of an item
- This example demonstrates how to use the Item property to return the value of an item.
- Set a key
- This example demonstrates how to use the Key property to set a key in a Dictionary object.
- Return the number of key/item pairs
- This example demonstrates how to use the Count property to return the number of key/item pairs.
AdRotator Component
- Simple AdRotator Example
- This example shows: how to use the AdRotator component to display a different advertisement image each time a user visits the website or refreshes a page.
- AdRotator - Image Link
- This example shows: how to use the AdRotator component to display a different advertisement image each time a user visits the website or refreshes a page. Moreover, the image itself is a link.
Browser Capabilities Component
- Browser Capabilities Component
- This example demonstrates how to determine the type, performance, and version number of the browser for each visitor to the website.
Content Linking Component
- Content Linking Component
- This example will build a content list.
- Content Linking Component 2
- This example uses the Content Linking component to navigate between pages listed in a text file.
Content Rotator (ASP 3.0)
- Content Rotator Component
- This component will display different HTML content strings each time a user visits or refreshes the page.
- Previous Page ASP Course Summary
- Next Page ASP Quiz