"" The...">

Conditional ASP error

I'm trying to use an ASP conditional here:

if (Request.Cookies("username")) and
(Request.Cookies("password")) <> ""
Then

      

And I keep getting this error:

Type mismatch: '[string: ""]'

Any ideas what I am getting this?

0


source to share


2 answers


try



if (Request.Cookies("username") <> "") and (Request.Cookies("password") <> "") Then

      

+2


source


Actually, I would do the following.

if (!string.IsNullOrEmpty(Request.Cookies("username")) &&
    !string.IsNullOrEmpty(Request.Cookies("password")))
{
    // Do your stuff, here :)
}

      



Get in the habit of using string.IsNullOrEmpty

for testing variables and string.Empty

for setting values ​​if u doesn't want the string to be null

.

-2


source







All Articles