views:

10

answers:

2

I have a page which will have these urls,

http://localhost:1218/Order-AUG17/Forms/Order.aspx?ContactName=HajaMubeen and
http://localhost:1218/Order-AUG17/Forms/Order.aspx

and in my page load i have checked this,

if (Request.QueryString["ContactName"] != "")
   //My logic
else
    //My logic

But this if condition fails for both the urls. Any suggestion.

+1  A: 

try

if (Request.QueryString["ContactName"] != null)
   //My logic
else
    //My logic
Carter
+1  A: 

if you are trying with

http://localhost:1218/Order-AUG17/Forms/Order.aspx

both will be false only. because no query string is there in the URL.It comes as null

if (Request.QueryString["ContactName"] != "")
   //My logic
else
    //My logic

if you are trying with

http://localhost:1218/Order-AUG17/Forms/Order.aspx?ContactName=HajaMubeen

if (Request.QueryString["ContactName"] != "")
       //My logic
    else
        //My logic

it will consider the if condition and execute that loop.

anishmarokey
@anish null seems to have worked.
Pandiya Chendur