
288
|
Chapter 13: The HttpApplicationState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Value
An Object argument containing the new value of the Application collection
object to be updated.
Example
The example uses Set twice—once to set a new item in the Application collection
and again to change that value.
Sub Page_Load( )
Application.RemoveAll( )
Application.Set("TotallyNewVariable","Test!")
Message.Text = "First: " + Application("TotallyNewVariable") + "<br/>"
Application.Set("TotallyNewVariable","Test again!")
Message.Text = Message.Text & "First after Set: " +
Application("TotallyNewVariable") + "<br/>"
End Sub
Notes
Set can be used to add values to the Application collection, but you will normally
just use the simple syntax you are used to from classic ASP:
Application("TotallyNewVariable") = "Test!"
UnLock
Application.UnLock
Unlocks access to an Application collection to facilitate access synchronization.
Parameters
None.
Example
The example locks the application, sets an application page load counter vari-
able, unlocks the application, and displays the value:
Sub Page_Load( )
Application.Lock( )
Application("Counter") = Application("Counter") + 1
Application.UnLock( )
Message.Text = "Counter = " & Application("Counter")
End Sub
Notes
In the example, note that we Lock the application, perform any operations that
modify values ...