首页 > Web开发 > 详细

ASP cookie

时间:2015-03-21 09:40:54      阅读:344      评论:0      收藏:0      [点我收藏+]

http://stackoverflow.com/questions/183254/what-is-a-postback

when a button is clicked, data will be send to server as a POST request. After server reply, the page will be refreshed. that is Page_Load() will be called, then the Button_click() will be called. if you don‘t want the page_load change to data back to old state, use

if (!Page.IsPostBack)
protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie ck = Request.Cookies["xx"];
            if (ck == null)
            {
                TextBox_info.Text = "hello new user!";
            }
            else if (!Page.IsPostBack)
            {
                TextBox_email.Text = ck[EMAIL];
                TextBox_password.Attributes.Add("value",ck[PASSWORD]);
            }
        }
 protected void Button2_Click(object sender, EventArgs e)
        {
            HttpCookie ck = new HttpCookie("xx");
            string email = TextBox_email.Text;
            string password = TextBox_password.Text;
            
            ck[EMAIL] = email;
            ck[PASSWORD] = password;
            ck.Expires = DateTime.Now.AddMonths(1);
            Response.Cookies.Add(ck);
        }

 

ASP cookie

原文:http://www.cnblogs.com/phoenix13suns/p/4355121.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!