| << 8.2.1- Application Variables | Chapter8 | 8.2.3- Application Object Methods >> |
Application Object Collections
The Application object has two Collections:
- The Contents collection contains all variables that have been added to the application via a script command. You can use this list to obtain a list of items that have been given application scope. You can also remove them with the addition of two new methods within ASP 3.0
- The StaticObjects collection contains the names of all objects added via the <OBJECT> tag in global.asa, with application scope, that is with SCOPE=APPLICATION. Objects that are added to global.asa can either be application-scoped objects or session-scoped objects, but session-scoped object belong to the Session.StaticObjects collection.
The Contents Collection
You use the Contents collection to get a list of items with application scope or to set a value for a particular Application-level variable.
The general syntax for retrieving a variable's value in the Application.Contents collection is:
Application.Contents("Key")
where Key specifies the name of the key to retrieve.
As Contents is the default collection, you could also use:
Application("Key" )
to specify it as well.
You can iterate through the Contents collection the same way you would for any collection, with a For...Each statement. An example of this is:
<%
For Each Key in Application.Contents
Response.Write (Key)
Next
%>
Just as with a normal collection, you can retrieve the number of elements in the collection by using the Count property.
<%= Application.Contents.Count %>
The StaticObjects Collection
The StaticObjects collection contains all the objects that have been created using the <OBJECT> tag, and that fall within the Application object's scope. You can use the StaticObjects collection to determine the value of an <OBJECT>'s property. Alternatively you can iterate through the collection, and retrieve properties for all the objects stored. We will see how to create static objects when we take a deeper look at the global.asa file.
| << 8.2.1- Application Variables | Chapter8 | 8.2.3- Application Object Methods >> |

RSS

