2008-12-06 21 views
0

我想在這裏使用ASP條件:ASP條件誤差

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

,我不斷收到此錯誤:

Type mismatch: '[string: ""]'

任何想法我收到了嗎?

回答

2

嘗試

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

謝謝......它工作得很好! – Coughlin 2008-12-06 23:25:46

+0

很高興能幫到你:) – hmcclungiii 2008-12-06 23:27:03

-2

事實上,我會做下列..

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

養成使用string.IsNullOrEmpty測試變量和string.Empty用於設置值的習慣,如果你不希望字符串爲null