[thelist] does JavaScript have an equivalent to IsDefined()?

Glenn Carr glenn at glenncarr.com
Mon Sep 22 17:16:12 CDT 2003

> This is server-side. When I do Response.Write(Request.QueryString('id')),
> get undefined, but if I try to compare to undefined, i.e...
>    if (Request.QueryString('id') != undefined) { }
> ...the code executes (incorrectly), and an error is thrown because the
> query that follows craps out on the undefined value. *Very* perplexing!
> (BTW, I've tried comparing to both undefined and 'undefined', same results
> with each - which is correct?)


This should work:

if ( Request.QueryString('id').Item == 'undefined' )
    Response.Write( 'id is not present in query string );
    Response.Write( 'id is present in query string );

The key is to use the Item property explicitly:

Response.Write( Request.QueryString('id').Item + '<br/>' );
Response.Write( Request.QueryString('id') + '<br/>' );

...will produce:


More information about the thelist mailing list