
284
|
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 = "There are " & Application.Count & _
" items in the Application collection."
End Sub
Notes
The Clear method, which is new for ASP.NET, clears only the contents of the
Application collection itself. It does not clear the contents of the StaticObjects
collection.
Get
Application.Get(ByVal name As String)
Application.Get(ByVal
Index As Integer)
Gets an element of the Application collection either by name or ordinal position
(index) within the Application collection. Generally, the name is used in calls to
Get unless you need to get members of the collection inside a loop.
Parameters
name
A variable of type String that specifies the name of the item to be retrieved
from the Application collection.
Index
A variable of type Integer that specifies the index of the item to be retrieved
from the Application collection.
Example
The example below sets and gets a value from the Application collection. It also
uses the Get method to write a message to the Text property of the Message
control that includes the current value of the newly added element of the Applica-
tion collection.
Sub Page_Load( )
Application("GetTest") = "Got it!"
Message.Text = "GetTest = " & Application.Get("GetTest")
End Sub
Notes
You can see whether a named value is saved