Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isset() in asp

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
How do I test if a querystring is set in ASP

The php equivalent would be if(isset($_GET['item']))

is there an if isset(request.querystring("item"))

type function
 
Basically if you call for a QueryString item that does not exist it passes you an empty string (which i find much easier then the PHP methods for checking, darn optonal errors):
Code:
If Request.QueryString("aField") = "" Then
   Response.Write "It don't exist!"
Else
   Response.Write "aField is " & Request.QueryString("aField")
End If

You can also use things like <> or even length checks. Basically it gives you an empty string for non-existent fields, which means that whether or not there was an input on the previous page with that name, you can check for both empty input values and no input field by that name in one easy statement.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
This code will also report "it doesn't exist" for zero-length values (blah.asp?aField=). If you have to make that kind of distinction, use IsEmpty(Request.QueryString("aField")).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top