Freshers Aptitude technical questions
Freshers Job Alert
Bookmark and Share

  Application Contents

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 with the Remove and RemoveAll methods.

Syntax

Application.Contents ( Key )

Parameters

Key

Specifies the name of the item to retrieve.

Methods

Contents.Remove

Deletes an item from the collection.

Contents.RemoveAll

Deletes all items from the collection.

Remarks

The Application.Contents collection contains those items that have been declared at the application level without using the <OBJECT> tags. This would include both objects created with 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 Application.Contents collection:

<% Application("strHello") = "Hello" Set Application("objCustom") = Server.CreateObject("MyComponent") %>

The Application.Contents collection supports For...Each and For...Next iteration. The following script illustrates each of these methods of iterating through the Application.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

%>