Cookies

K

Keld

have a problem with saving values into cookies.

In a grid i have a imagebutton which which rowcommand looks like this

Dim BookMarkCookie As New
HttpCookie("BookMarks")
BookMarkCookie.Value = MyID
BookMarkCookie.Expires =
DateAdd(DateInterval.Day, 30, Now)
Response.AppendCookie(BookMarkCookie)
System.Threading.Thread.Sleep(1000)
Me.Source_SearchGrid.SelectCommand =
Me.hiddenSQL.Value
Me.SearchGrid.DataSource = Source_SearchGrid
Source_SearchGrid.DataBind()
SearchGrid.PageIndex = SearchGrid.PageIndex
Me.SearchGrid.DataBind()

On Search Databind i have

Protected Sub Source_SearchGrid_DataBinding(ByVal sender As Object, ByVal e
As System.EventArgs)
Try
Dim CurrentCookie As HttpCookie = Request.Cookies("BookMarks")
BookMarks = CurrentCookie.Value
Catch ex As Exception
BookMarks = ""
End Try
End Sub

But BookMarks doesnt have the value set on click. Only after the 3 roundtrip
the cookie value is getting right.

Can anyone help
 
G

Guest

well you set a response cookie, then call databind, which looks at the
request cookie, which will not have the new value until the next request. I
have no idea what the sleep is for.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Cookies 1
problem with cookies and graphics 0
Cookies Count 2
cookies.... 1
cookies question 3
httpCookie is null 4
What is the proper way to use cookies? 1
No-Postback Reload Causing Duplicates :( 0

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top