
Abandon | 415
SessionState
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
each object and, if it is a TextBox web control, adds it to the Controls collection
of the form:
Sub Page_Load( )
Message.Text = "There are " & Session.StaticObjects.Count & _
" objects declared with the " & _
"<object runat="server"> syntax in Session scope."
Dim myobj As Object
For Each myObj in Session.StaticObjects
If myObj.Value.GetType.ToString( ) = _
"System.Web.UI.WebControls.TextBox" Then
myForm.Controls.Add(myObj.Value)
End If
Next
End Sub
You also need to modify the <body> section of the document as follows:
<body>
<form id="myForm" runat="server">
<asp:label id="Message" runat="server"/>
</form>
</body>
Notes
This property is provided for backward compatibility with classic ASP. You
should think carefully before instantiating objects with Session or Application
scope because of the impact such objects have on resource usage and application
scalability. In most cases, it is advisable to limit objects to page scope.
Each object in the collection is represented by the DictionaryEntry structure, so its
key and value are not directly accessible. To access the key and/or value, use the
Key and/or Value members of the DictionaryEntry structure, as shown in the
example.
Methods Reference
Abandon
Session.Abandon( )
Immediately terminates ...