本文整理匯總了C#中System.Web.UI.UserControl.Session屬性的典型用法代碼示例。如果您正苦於以下問題:C# UserControl.Session屬性的具體用法?C# UserControl.Session怎麽用?C# UserControl.Session使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Web.UI.UserControl
的用法示例。
在下文中一共展示了UserControl.Session屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SubmitBtn_Click
// Save state information which is used by display handler after the postback has occurred.
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;
}