
282
|
Chapter 13: The HttpApplicationState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Message.Text = "Application Keys:"
For Each Key in Application.Keys
Message.Text &= "<br/>Key: " & Key
Message.Text &= "<br/>Value: " & Application(Key)
Next
End Sub
Notes
The Keys property provides one of many ways to iterate over the contents of the
Application collection.
StaticObjects
HttpStaticObjectsCollection = Application.StaticObjects
Returns an HttpStaticObjectsCollection containing all objects instantiated in
global.asax using the
<object runat="server"> syntax whose scope attribute is set
to
Application.
Parameter
HttpStaticObjectsCollection
A variable of type HttpStaticObjectsCollection that will receive the StaticOb-
jects property value.
Example
The example uses the Count property of the HttpStaticObjectsCollection class to
display the number of objects in the current application declared with the
<object
scope="Application" runat="server"/>
syntax in global.asax. It then checks the
type of each object, and if it is a Web TextBox control, adds it to the Controls
collection of the current page.
Sub Page_Load( )
Message.Text = "There are " & Application.StaticObjects.Count & _
" objects declared with the " & _
"<object runat="server"> syntax " & _
"in Application scope."
Dim myobj As ...