|
-
Jul 5th, 2007, 04:53 AM
#1
Thread Starter
Addicted Member
Error to retrieve data from cookies
Hi
I have created cookies in asp.net that is the below coding
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newCookie As HttpCookie
newCookie = New HttpCookie("Books")
newCookie.Values.Add("Name", TextBox1.Text)
newCookie.Values.Add("FavBook", RadioButtonList1.SelectedItem.Text)
newCookie.Expires = #12/12/2008#
newCookie.Path = ("C:/Documents and Settings/ashok.I-WAVES.001/Cookies/")
Response.Cookies.Add(newCookie)
Label1.Text = "Cookies Created"
Button1.Visible = False
TextBox1.Visible = False
Label2.Visible = False
Label3.Visible = False
RadioButtonList1.Visible = False
End Sub
But I cant retrieve the data .The below code is used to retrieve data.Can u tell whts the error in that coding and what reason?
Protected Sub Retrieve_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Retrieve.Click
Try
Label1.Visible = False
Label4.Text = "Hello" & " " & Request.Cookies("Books")("Name") & "." &_ "We have a new book for you:"
If Request.Cookies("Books")("FavBook") = "C" Then
Label5.Text = "ABC C Book"
ElseIf Request.Cookies("Books")("FavBook") = "C#" Then
Label5.Text = "XYZ C Book"
Else
Label5.Text = "C++"
End If
Catch ex As Exception
End Try
End Sub
End Class
Thanks
Failing to plan is Planning to fail
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|