ASP.Net/Session Cookie/Static Objects

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Get session static objects (VB.net)

   <source lang="csharp">

<%@ Page Language="vb" %> <html>

  <head>
     <script runat="server">
        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
     </script>
  </head>

<body>

  <form id="myForm" runat="server">
     <asp:label id="Message" runat="server"/>
  </form>

</body> </html>

      </source>