testing for querystring

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.
 
A

Aidy

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
 
A

Aidy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top