Save Cookie (Vb.net) : Cookie « Session Cookie « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Session Cookie » Cookie 
Save Cookie (Vb.net)

<%@ Page Language="VB" %>
  <script language="vb" runat="server">
      Sub Page_Load(Source As Object, E as EventArgs)
        If Not IsPostBack Then
          MyButton.Text = "Save Cookie"
          MyDropDownList.Items.Add("Blue")
          MyDropDownList.Items.Add("Red")
          MyDropDownList.Items.Add("Gray")
        End If
      End Sub
    Public Sub Click(ByVal sender As Object, ByVal e As System.EventArgs)
      Dim MyCookie As New HttpCookie("Background")
      MyCookie.Value = MyDropDownList.SelectedItem.Text
      Response.Cookies.Add(MyCookie)   
      End Sub
  </script>
<html>
  <body>
    <form id="CookieForm" method="post" runat="server">
      <asp:DropDownList id=MyDropDownList runat="server"/>
      <asp:button id=MyButton runat="server" OnClick="Click"/>
    </form>
  </body>
</html>


//////////////////////////////////////////////////////////
// Get saved Cookies 
<%@ Page Language="VB" %>
  <script language="vb" runat="server">
    Sub Page_Load(Source As Object, E as EventArgs)
      Response.Cache.SetExpires(DateTime.Now)
    End Sub
  </script>
  <html>
    <body bgcolor="<%=Request.Cookies("Background").Value%>">
    </body>
  </html>


           
       
Related examples in the same category
1.Create and retrieve Cookie data (C#)
2.Display all Cookie (C#)
3.Delete Cookie (C#)
4.Delete All Cookies (C#)
5.Setting a Cookie (VB.net)
6.Adding cache dependencies (VB.net)
7.Getting cookie values in ASP.NET
8.Setting expire date and path for cookies in ASP.NET (VHB.net)
9.Write Cookie and read Cookie (VB.net)
10.Save and retrieve values in Cookie (C#)
11.Set cookie expire date (VB.net)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.