Here simple code for creating cookie and value show on button click..!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
HttpCookie mycookie = new HttpCookie("malvik");
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["malvik"] != null)
{
Response.Write(Request.Cookies["malvik"].Value);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
mycookie.Value = TextBox1.Text;
mycookie.Expires = DateTime.Now.AddMinutes(1);
Response.Cookies.Add(mycookie);
}
protected void btn1_Click(object sender, EventArgs e)
{
Page.Theme = "Theme1";
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
HttpCookie mycookie = new HttpCookie("malvik");
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["malvik"] != null)
{
Response.Write(Request.Cookies["malvik"].Value);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
mycookie.Value = TextBox1.Text;
mycookie.Expires = DateTime.Now.AddMinutes(1);
Response.Cookies.Add(mycookie);
}
protected void btn1_Click(object sender, EventArgs e)
{
Page.Theme = "Theme1";
}
}
Post a Comment