用户自定义事件中:
string content = txtcontent.Text.Trim();
string title = txttitle.Text.Trim();
if (Session["User"] == null)
{
//还没登录转向登录页进行登录
Response.Cookies["content"].Value = content;
Response.Cookies["title"].Value = title;
//编码后才不会被抹掉
string url = Server.UrlEncode(Request.Url.ToString());
Response.Redirect(string.Format("/login.aspx?page={0}", url));
}
页面第一次加载时:
if (Request.Cookies["title"] != null)
{
txttitle.Text = Request.Cookies["title"].Value;
Response.Cookies["title"].Value = null;
}
if (Request.Cookies["content"] != null)
{
txtcontent.Text = Request.Cookies["content"].Value;
Response.Cookies["content"].Value = null;
}