Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft das HttpSessionState-Objekt für die aktuelle Webanforderung ab.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public ReadOnly Property Session As HttpSessionState
'Usage
Dim instance As UserControl
Dim value As HttpSessionState
value = instance.Session
public HttpSessionState Session { get; }
public:
property HttpSessionState^ Session {
HttpSessionState^ get ();
}
/** @property */
public HttpSessionState get_Session ()
public function get Session () : HttpSessionState
Eigenschaftenwert
Das HttpSessionState-Objekt, das der Page mit der UserControl-Instanz zugeordnet ist.
Beispiel
Im folgenden Beispiel werden der Session-Eigenschaft eines Benutzersteuerelements Werte hinzugefügt. Durch die myControl.Session.Add-Syntax werden die Werte zweier TextBox-Webserver-Steuerelemente der Sitzung hinzugefügt, die mit dem Benutzersteuerelement und der enthaltenden Seite verknüpft ist.
' Saves state information which is used by display handler after the postback has occured.
Sub SubmitBtn_Click(Sender As Object, e As EventArgs)
' Clear all values from session state of 'Page'.
Session.Clear()
' Populate Session State of UserControl with the values entered by user.
myControl.Session.Add("username",myControl.user.Text)
myControl.Session.Add("password",myControl.password.Text)
' Add UserControl state to the SessionState object of Page.
Session(myControl.user.Text)= myControl
Display.Enabled = true
End Sub
Sub Display_Click(Sender As Object,e As EventArgs)
Dim position As Integer = Session.Count - 1
' Extract stored UserControl from the session state of page.
Dim tempControl As LogOnControl = CType(Session(Session.Keys(position)),LogOnControl)
' Use SessionState of UserControl to display previously typed information.
txtSession.Text = "<br><br>User:" + tempControl.Session("username") + "<br>Password : " + tempControl.Session("password")
Display.Enabled = false
End Sub
// Save state information which is used by display handler after the postback has occured.
void SubmitBtn_Click(Object sender, EventArgs e)
{
// Clear all values from session state of 'Page'.
Session.Clear();
// Populate Session State of UserControl with the values entered by user.
myControl.Session.Add("username",myControl.user.Text);
myControl.Session.Add("password",myControl.password.Text);
// Add UserControl state to the SessionState object of Page.
Session[myControl.user.Text]= myControl;
display.Enabled = true;
}
void Display_Click(Object sender, EventArgs e)
{
int position = Session.Count - 1;
// Extract stored UserControl from the session state of page.
LogOnControl tempControl = (LogOnControl)Session[Session.Keys[position]];
// Use SessionState of UserControl to display previously typed information.
txtSession.Text = "<br><br>User:" + tempControl.Session["username"] + "<br>Password : " + tempControl.Session["password"];
display.Enabled = false;
}
// Save state information which is used by display handler after the
// postback has occured.
void SubmitBtn_Click(Object sender, EventArgs e)
{
// Clear all values from session state of 'Page'.
get_Session().Clear();
// Populate Session State of UserControl with the values entered by user.
myControl.get_Session().Add("username",myControl.user.get_Text());
myControl.get_Session().Add("password",myControl.password.get_Text());
// Add UserControl state to the SessionState object of Page.
get_Session() .set_Item( myControl.user.get_Text() , myControl );
display.set_Enabled(true);
} //SubmitBtn_Click
void Display_Click(Object sender, EventArgs e)
{
int position = get_Session().get_Count() - 1;
// Extract stored UserControl from the session state of page.
LogOnControl tempControl = (LogOnControl)(get_Session().get_Item(
get_Session().get_Keys().get_Item(position)));
// Use SessionState of UserControl to display previously typed
// information.
txtSession.set_Text("<br><br>User:"
+ tempControl.get_Session().get_Item("username") + "<br>Password : "
+ tempControl.get_Session().get_Item("password"));
display.set_Enabled(false);
} //Display_Click
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
UserControl-Klasse
UserControl-Member
System.Web.UI-Namespace
Page.Session-Eigenschaft
HttpSessionState-Klasse