Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
Cookie
//将数据保存到Cookie
//Cookie是一个字典
//如果没有指定Cookie的保存时间,则这个Cookie是临时Cookie
//临时Cookie只要浏览器一关闭,就取消
//Response.Cookies["account"].Value = txt1.Text;
//如果指定了Cookie的保存时间,这个Cookie就叫持久Cookie
Response.Cookies["account"].Value =
txt1.Text;
Response.Cookies["account"].Expires = DateTime.Now.AddMinutes(1);
//Response.Cookies["account"].Expires = DateTime.Now.AddMinutes(-1);
if
(Request.Cookies["account"] != null)
{
lab1.Text = Request.Cookies["account"].Value;
}
ViewState
利用ViewState保持页面状态_页面状态对象
protectedvoid
btn3_Click(object sender, EventArgs
e)
{
a =
10;
b =
20;
//ViewState是一个字典,键值对
//ViewState用于本页面回发时保持状态
ViewState["a"] = a;
ViewState["b"] = b;
}
protectedvoid
btn4_Click(object sender, EventArgs
e)
{
a = Convert.ToInt32(ViewState["a"]);
b = Convert.ToInt32(ViewState["b"]);
c = a
+ b;
lab2.Text = c.ToString();
}
Session
Session["username"] = txt1.Text;
if
(Session["username"] != null)
{
lab1.Text = Session["username"].ToString();
}
Application公共对象
//因为Application对象时公共对象
//当多个用户同时修改Application对象时,可能会引发不可预知的问题
//并发
Application.Lock();//锁定对象
//Application.Add("account",
txt1.Text);
Application["account"] =
txt1.Text;
//...
Application.UnLock();//解锁对象
if (Application["account"] != null)
{
lab1.Text = Application["account"].ToString();
}
//ViewState是一个字典,键值对
//ViewState用于本页面回发时保持状态
ViewState["a"] = a;
ViewState["b"] = b;