Author: foolios | Posted on: 3/26/2007 6:31:25 PM | Views : 246

I have noticed a strange occurrence that happens in the button click
event userBttn_Click. On the first time through the loop the cookie
doesn't update. But when the button is clicked on a second time, then
it does.

I also noticed that the if check in that button click event does not
ever result in true even when I they are appear to be equal at the line:

if (practiceCookie["UserName"] == Session["CurrentUser"].ToString())



I thought maybe they both needed to be converted to string:

if (practiceCookie["UserName"].ToString() == Session["CurrentUser"].ToString())



but I then get the error:

Object reference not set to an instance of an object when I do that.



So, basically I can update the cookie after a second attempt but that's
not desireable. I would like it to work on the first click and postback
to the page. I thought I had the statements out of order but they seem
to be in order to me. Here is the full cod ...

Go to the complete details ...