Cookies

K

Keld

I 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

Hi Keld,

Sometime the problem is else where then where we look for. can you check
your page_load event to confirm that init code written is within
If(Page.IsPostback) block.

Regards
JIGNESH
 

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,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top