ASP Contents Collection

The ASP Contents Collection is used for collecting the items which are appended to the Application object by using script command.  This Collection can also be used to provide a list of items that have been given application scope, 

The Contents.Remove and Contents.RemoveAll methods can be used to remove some or all of the items from the collection. 

Syntax

Application.Contents(Key) 

Parameter Values:

  • Key: It contains a single value i.e Key which represents the name of the items.

Example 1: We use to add names and objects that would be added to the contents collections.

<%
Application("name")="w3wiki"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%> 

Example 2: 

<%
Application("author")="w3wiki"
Application("Contributors")="Rahul Jain"

for each x in Application.Contents
 Response.Write(x & "=" & Application.Contents(x) & "<br>")
next
%>

Output 

author=w3wiki
Contributors=Rahul Jain