最近,我电脑出问题重装了,以前做的练习都没了所以得重做,我记得:以前做这个时没有问题的呀?怎么这次就乱码了呢? 而且,我在页面上拖放的一个Label 也是在后台赋值显示却没问题呢?代码如下: protected void btnWriteCookis_Click(object sender, EventArgs e)
{//写入Cookis
HttpCookie w = new HttpCookie("newCookis");
w.Values["name"] = "李凯峰";
w.Values["age"] = "110";
w.Values["time"] = DateTime.Now.ToString();
Response.Cookies.Add(w);//写入
Response.Write("<script language='JavaScript'>alert('ok')</script>");
}
protected void btnReadCookis_Click(object sender, EventArgs e)
{//读出、并显示Cookis
HttpCookie r = Request.Cookies["newCookis"];
Label lbl1 = new Label();
Label lbl2 = new Label();
Label lbl3 = new Label();
lbl1.Text = r.Values["name"].ToString();
lbl2.Text = r.Values["age"];
lbl3.Text = r.Values["teme"];
this.Panel1.Controls.Add(lbl1);
this.Panel1.Controls.Add(lbl2);
this.Panel1.Controls.Add(lbl3);
//Response.Write(r.Values["name"]);
//Response.Write(r.Values["age"]);
//Response.Write(r.Values["time"]);
this.Label1.Text = "这里也不能显示中文么?";//这个在布面上显示没问题!
}
{//写入Cookis
HttpCookie w = new HttpCookie("newCookis");
w.Values["name"] = "李凯峰";
w.Values["age"] = "110";
w.Values["time"] = DateTime.Now.ToString();
Response.Cookies.Add(w);//写入
Response.Write("<script language='JavaScript'>alert('ok')</script>");
}
protected void btnReadCookis_Click(object sender, EventArgs e)
{//读出、并显示Cookis
HttpCookie r = Request.Cookies["newCookis"];
Label lbl1 = new Label();
Label lbl2 = new Label();
Label lbl3 = new Label();
lbl1.Text = r.Values["name"].ToString();
lbl2.Text = r.Values["age"];
lbl3.Text = r.Values["teme"];
this.Panel1.Controls.Add(lbl1);
this.Panel1.Controls.Add(lbl2);
this.Panel1.Controls.Add(lbl3);
//Response.Write(r.Values["name"]);
//Response.Write(r.Values["age"]);
//Response.Write(r.Values["time"]);
this.Label1.Text = "这里也不能显示中文么?";//这个在布面上显示没问题!
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货