本文整理汇总了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;
}