List Info

Thread: RE: Checking for the existence of a key in a querystring




RE: Checking for the existence of a key in a querystring
country flaguser name
United States
2008-04-24 01:21:58
Check

if (Request.QueryString["catagory"] != null) {
    label.Text = Request.QueryString["catagory"];
}


James Smith wrote:
> I am using the querystring to get information into a
page similar to
> "products.aspx?catagory=DVD".  I want some
way to check for the keys
> existence before I use it.  For example...
>
> if (check for existence) {
>     label.Text =
Request.QueryString["catagory"];
> }
>
> How would I do that?
>
>   

"Confidentiality Warning: This message and any
attachments are intended only for the use of the intended
recipient(s), 
are confidential, and may be privileged. If you are not the
intended recipient, you are hereby notified that any 
review, re-transmission, conversion to hard copy, copying,
circulation or other use of this message and any attachments
is 
strictly prohibited. If you are not the intended recipient,
please notify the sender immediately by return email, 
and delete this message and any attachments from your
system.

Virus Warning: Although the company has taken reasonable
precautions to ensure no viruses are present in this email,

the company cannot accept responsibility for any loss or
damage arising from the use of this email or
attachment."



--- List Settings ---
http://aspadvice.com/list
s/


RE: Checking for the existence of a key in a querystring
country flaguser name
United States
2008-04-25 08:06:23
>  if (Request.QueryString["catagory"] != null)
{
>
>     label.Text =
Request.QueryString["catagory"];
>  }

This looks like the way to go, in ColdFusion (my previous
language)
accessing a variable that didn't exist would have caused an
error so
you used the isDefined() function to check for existence but
if I can
just check it for NULL that will do the same job.  I also
like the
String.IsNullOrEmpty() function.  Will play with both
later.

Cheers.

--
Jay


--- List Settings ---
http://aspadvice.com/list
s/


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )