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

本文详细介绍了如何在用户自定义事件中处理页面加载,包括登录验证、内容存储与检索,以及页面初次加载时的预设操作。

用户自定义事件中:

  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;

                }

转载于:https://www.cnblogs.com/yinxiaofeng/archive/2012/07/29/2614041.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值