Cookies

  • Thread starter Thread starter Keld
  • Start date Start date
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
 
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)
 
Back
Top