Application.Contents Collection
The Contents collection contains all the items that have been added to the application through a script command. You can use the Contents collection to obtain a list of items that have been given application scope or to specify a particular item to be the target of an operation. You can also remove items from the collection by using the Remove and RemoveAll methods.
Syntax
Application.Contents( Key)
Parameters
- Key
Specifies the name of the item to retrieve.
Methods
Deletes an item from the collection. |
|
Deletes all items from the collection. |
Remarks
The Contents collection contains those items that have been declared at the application level without using the <OBJECT> tags. This would include both objects created by using Server.CreateObject, as well as scalar variables established through an Application declaration. In the following script, for example, both "strHello" and objCustom would be members of the Contents collection.
<%
Application("strHello") = "Hello"
Set Application("objCustom") = Server.CreateObject("MyComponent") %>
The Contents collection supports For...Each and For...Next iteration. The following script illustrates each of these methods of iterating through the Contents collection:
<%
Application("strText1") = "1234567890"
Application("strText2") = "ABCDEFGHIJ"
Application("strText3") = "A1B2C3D4E5"
%>
<%
For Each Key in Application.Contents
Response.Write Key + " = " + Application(Key) + "<BR>"
Next
%>
<%
For intItem = 1 to Application.Contents.Count
Response.Write CStr(intItem) + " = "
Response.Write Application.Contents(intItem) + "<BR>"
Next
%>
Requirements
Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Product: IIS