<%@ 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>
|