页面回调时参数保存原样,并且可以讲保存先前用户的输入的值

用户自定义事件中:

  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;

                }

posted on 2012-07-29 15:30  yxfaction  阅读(238)  评论(0编辑  收藏  举报

导航