Hammy Posted February 28, 2003 Posted February 28, 2003 Hi, I am working through an ASP.NET book, and I have a question about a piece of code..... On a login page, if the username/password match, we set a cookie "FirstName" then redirect to another page. On the redirected page, we have a page_load event as follows.... sub Page_Load(obj as object, e as eventargs) If (Request.Cookies("FirstName") is Nothing) Then lblWelcomeMessage.Text = "Welcome <b>" & _ Request.Cookies("FirstName").Value & "!</b>" End If End Sub Okay, I follow all of it, except for the "IS Nothing" can someone please tell me what "IS Nothing" is checking, and why we are using it in this context? To me, it SOUNDS like it is checking that the cookie is blank, but obviously this not the case. Sooooooooo what does "Is Nothing" check, so I can know for future reference? Thanks, Hammy Quote
Moderators Robby Posted March 1, 2003 Moderators Posted March 1, 2003 It checks if the object exists. You can also fet rid of the extra brackets, and shouldn't it be ... If Not Request.Cookies("FirstName") is Nothing Then Quote Visit...Bassic Software
Hammy Posted March 1, 2003 Author Posted March 1, 2003 I don't know, that's why I am asking..... If... If Request.Cookies("FirstName") Is Nothing evaluates to true, does that mean the FirstName cookie exists, or doesn't exist? Hammy Quote
Moderators Robby Posted March 1, 2003 Moderators Posted March 1, 2003 If... If Request.Cookies("FirstName") Is Nothing evaluates to True then the object is not set (That means it Is Nothing) Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.