Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents txtCookie1 As System.Web.UI.WebControls.TextBox Protected WithEvents DelCookie3 As System.Web.UI.WebControls.Button Protected WithEvents DelCookie2 As System.Web.UI.WebControls.Button Protected WithEvents Label4 As System.Web.UI.WebControls.Label Protected WithEvents Label3 As System.Web.UI.WebControls.Label Protected WithEvents Label2 As System.Web.UI.WebControls.Label Protected WithEvents GetCookies As System.Web.UI.WebControls.Button Protected WithEvents DelCookie1 As System.Web.UI.WebControls.Button Protected WithEvents AddCookie3 As System.Web.UI.WebControls.Button Protected WithEvents AddCookie2 As System.Web.UI.WebControls.Button Protected WithEvents txtCookie3 As System.Web.UI.WebControls.TextBox Protected WithEvents txtCookie2 As System.Web.UI.WebControls.TextBox Protected WithEvents AddCookie1 As System.Web.UI.WebControls.Button Protected WithEvents Label1 As System.Web.UI.WebControls.Label #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub AddCookie1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddCookie1.Click Dim cookie As New HttpCookie("User" & txtCookie1.Text) cookie.Value = txtCookie1.Text Response.Cookies.Add(cookie) End Sub Private Sub GetCookies_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetCookies.Click Dim i As Integer Dim cookie As HttpCookie Label1.Text = "" For i = 0 To Request.Cookies.Count - 1 cookie = Request.Cookies.Item(i) Label1.Text &= "
" & cookie.Name.ToString & "" & cookie.Value.ToString Next Label1.Text &= "
" End Sub Private Sub AddCookie2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddCookie2.Click Dim cookie As New HttpCookie("EMail" & txtCookie2.Text) cookie.Value = txtCookie2.Text Response.Cookies.Add(cookie) End Sub Private Sub AddCookie3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddCookie3.Click Dim cookie As New HttpCookie("Title" & txtCookie3.Text) cookie.Value = txtCookie3.Text Response.Cookies.Add(cookie) End Sub Private Sub DelCookie1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DelCookie1.Click Response.Cookies("User" & txtCookie1.Text).Expires = Now End Sub Private Sub DelCookie2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DelCookie2.Click Response.Cookies("EMail" & txtCookie2.Text).Expires = Now End Sub Private Sub DelCookie3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DelCookie3.Click Response.Cookies("Title" & txtCookie3.Text).Expires = Now End Sub End Class