more cookie
-
protected void btnAdd_Click(object sender, EventArgs e) { Response.Cookies["message"].Value = "Hello World"; Response.Cookies["message"].Expires = DateTime.Now.AddDays(1); btnAdd.Text = Response.Cookies["message"].Value; Button1.Text = Response.Cookies["message"].Value; } protected void Button1_Click(object sender, EventArgs e) { if (Response.Cookies["message"] == null) Button1.Text = "null"; else Button1.Text = Response.Cookies["message"].Value; } when btnAdd)Click is executed it sets Button1.Text = btnAdd.Text = "Hello World"; but when Button1_Click is executed it sets Button1.Text = String.Empty. Why?
-
protected void btnAdd_Click(object sender, EventArgs e) { Response.Cookies["message"].Value = "Hello World"; Response.Cookies["message"].Expires = DateTime.Now.AddDays(1); btnAdd.Text = Response.Cookies["message"].Value; Button1.Text = Response.Cookies["message"].Value; } protected void Button1_Click(object sender, EventArgs e) { if (Response.Cookies["message"] == null) Button1.Text = "null"; else Button1.Text = Response.Cookies["message"].Value; } when btnAdd)Click is executed it sets Button1.Text = btnAdd.Text = "Hello World"; but when Button1_Click is executed it sets Button1.Text = String.Empty. Why?
hotthoughtguy wrote:
if (Response.Cookies["message"] == null) Button1.Text = "null"; else Button1.Text = Response.Cookies["message"].Value;
refer the cookie from request object rather than response.
if (Request.Cookies["message"] == null)
Button1.Text = "null";
else
Button1.Text = Request.Cookies["message"].Value;Regards, Prakash Kalakoti
-
hotthoughtguy wrote:
if (Response.Cookies["message"] == null) Button1.Text = "null"; else Button1.Text = Response.Cookies["message"].Value;
refer the cookie from request object rather than response.
if (Request.Cookies["message"] == null)
Button1.Text = "null";
else
Button1.Text = Request.Cookies["message"].Value;Regards, Prakash Kalakoti
yes its working with Request. thanks again