ASP script knows which names in "Name=Value" have

Results 1 to 4 of 4

Thread: ASP script knows which names in "Name=Value" have

  1. #1
    Join Date
    Dec 1969

    Default ASP script knows which names in "Name=Value" have

    Hi all,<BR><BR>My ASP script is processing a list, which I&#039m now finding necessary to subcategorize. Because of the flow of things, logic and the nature of the formatting, it seems to make sense to just use the same script, and test for parameters to know which level I&#039m (/the user is) at.<BR><BR>The question I have now: Is there a way to know if a certain parameter is in the Request.QueryString collection? In this way, the level/degree of sub-levels could be passed in. <BR><BR>I am sure that this is pretty simple, but I can&#039t seem to get focused on the solution, so TIA for any/every bit of advice!!<BR><BR>Dawn

  2. #2
    Join Date
    Dec 1969

    Default RE: ASP script knows which names in

    Yes. You can view the ENTIRE QueryString, like so:<BR><BR>Response.Write Request.QueryString<BR><BR>If you are wanting to know if a particular Name/Value pair exists in the querystring, simply do:<BR><BR>If InStr(1,Request.QueryString,"Name=Value",1) &#062; 0 then<BR>&#039Name/Value pair Name, Value exist<BR>Else<BR>&#039They don&#039t exist<BR>End If<BR><BR>(be sure to replace the "Name=Value" with the actual name and value that you are searching for!)<BR><BR>Happy programming!

  3. #3
    KPW Guest

    Default RE: ASP script knows which names in

    I think you could do this in a couple of different ways.<BR><BR>You could do<BR><BR>&#060;%<BR>if Request.QueryString("myFormVariable") &#060;&#062; "" then<BR> &#039 --- parameter was in the query string ---<BR>end if<BR>%&#062;<BR><BR>I think this would work also:<BR><BR>&#060;%<BR>Dim vVar<BR>Dim bVarExists<BR>for each vVar in Request.QueryString<BR> if vVar = "myFormVariable" then<BR> &#039 --- parameter was in the query string ---<BR> bVarExists = true<BR> end if<BR>next<BR><BR>if bVarExists then<BR> &#039 --- do stuff ---<BR>end if<BR>%&#062;<BR><BR>I hope this helps!

  4. #4
    Adrian Crooks Guest

    Default RE: ASP script knows which names in

    Please do not use the instr() function to find the parameter. This will cause errors if a value in the querystring so happens to be the same as the name you are looking for. EX: myasp.asp?test=strange<BR>The name is "test", and the value is "strange", but using instr will return true for both "test" and "strange".<BR><BR>The best way is to use the isEmpty() function EX: myasp.asp?test=strange<BR>Request("test") returns "strange"<BR>isEmpty(Request("test")) returns [false]<BR>Request("strange") returns [empty]<BR>isEmpty(Request("strange") returns [true]<BR><BR>Simply put, isEmpty() returns true if the parameter does not exist or is not yet defined.<BR>BTW: isEmpty() works best on variables/collections - not objects, as objects can be defined as [Nothing].

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts