我之前理解有误,楼主抱歉了,我改了下代码,代码如下:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Response.Cookies["name"].Value != null)
{
Response.Redirect("Default2.aspx");
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
Response.Cookies["name"].Value = TextBox1.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Redirect("Default2.aspx");
}
}
}
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.Cookies["name"].Value;
}
}
请注意我标红的行的写法
[ 本帖最后由 冰镇柠檬汁儿 于 2010-7-2 09:11 编辑 ]
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Response.Cookies["name"].Value != null)
{
Response.Redirect("Default2.aspx");
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
Response.Cookies["name"].Value = TextBox1.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Redirect("Default2.aspx");
}
}
}
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.Cookies["name"].Value;
}
}
请注意我标红的行的写法
[ 本帖最后由 冰镇柠檬汁儿 于 2010-7-2 09:11 编辑 ]
本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!