testing for querystring

  • Thread starter Thread starter Carlos
  • Start date Start date
C

Carlos

Hi all,

I would like to have a page that checks for an optional
parameter being passed.

I use the request.querystring("myvar") when the parameter is
being passed, but when the parameter is not passed I get an object reference
exception. How can I check for the existence of the variable being
passed?

Thanks,

Carlos.
 
c#
if (Request.QueryString["myvar"] != null)
// myvar exists
else
// it doesn't

vb.bet (I think)
if Request.QueryString("myvar") is nothing then
// exists
else
// doesn't
end if
 
Deliberate mistake in the vb.net section, reverse the "exists" and "doesn't"
:)

Aidy said:
c#
if (Request.QueryString["myvar"] != null)
// myvar exists
else
// it doesn't

vb.bet (I think)
if Request.QueryString("myvar") is nothing then
// exists
else
// doesn't
end if

Carlos said:
Hi all,

I would like to have a page that checks for an optional
parameter being passed.

I use the request.querystring("myvar") when the parameter is
being passed, but when the parameter is not passed I get an object
reference exception. How can I check for the existence of the variable
being
passed?

Thanks,

Carlos.
 
Back
Top