Can you tell me what this means

Hammy

Active member
Joined
Jan 15, 2003
Messages
27
Location
Ontario, Canada
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
 
It checks if the object exists.

You can also fet rid of the extra brackets, and shouldnt it be ...
Code:
If Not Request.Cookies("FirstName") is Nothing Then
 
I dont know, thats why I am asking.....

If...

If Request.Cookies("FirstName") Is Nothing

evaluates to true, does that mean the FirstName cookie exists, or doesnt exist?

Hammy
 
If...
If Request.Cookies("FirstName") Is Nothing

evaluates to True then the object is not set (That means it Is Nothing)
 


Write your reply...
Back
Top