469,352 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Check Existence of QueryString

What is the easiest way to check if a particular QueryString exists?

I want to know if the QueryString was ever passed rather than whether it
contains a value or not.
Jul 22 '05 #1
5 22252
"Keith" <@.> wrote in message news:e#**************@TK2MSFTNGP14.phx.gbl...
What is the easiest way to check if a particular QueryString exists?

I want to know if the QueryString was ever passed rather than whether it
contains a value or not.


What's the difference?

If Request.QueryString() <> "" Then {whatever}
Jul 22 '05 #2
Keith wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
What is the easiest way to check if a particular QueryString exists?

I want to know if the QueryString was ever passed rather than whether
it contains a value or not.

http://localhost/test.asp?qwerty=
and
http://localhost/test.asp?a=1&qwerty=zzz

using test.asp:

<%
response.write instr(request.querystring,"qwerty=")>0
%>

will both write:

True

=========================================

http://localhost/test.asp?qwertXy=7

will write:

False
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #3
Not to pick nits, and probably not a concern to the original poster but

test.asp?newdata=xxx
test.asp?morenewdata=yyy

would both get hits for "newdata="

If that is a possibility then a more complex condition must be checked.
Something like the following (not tested, may need tweaking)

lcase(left(request.querystring, len("newdata=")))="newdata=" Or _
instr(request.querystring,"&newdata=")>0

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Keith wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:
What is the easiest way to check if a particular QueryString exists?

I want to know if the QueryString was ever passed rather than whether
it contains a value or not.

http://localhost/test.asp?qwerty=
and
http://localhost/test.asp?a=1&qwerty=zzz

using test.asp:

<%
response.write instr(request.querystring,"qwerty=")>0
%>

will both write:

True

=========================================

http://localhost/test.asp?qwertXy=7

will write:

False
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #4
"Keith" <@.> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
What is the easiest way to check if a particular QueryString exists?

I want to know if the QueryString was ever passed rather than whether it
contains a value or not.


Response.Write IsEmpty(Request.Querystring("val"))
Jul 22 '05 #5
Chris Hohmann wrote:
Response.Write IsEmpty(Request.Querystring("val"))


More to the point, Request.QueryString("val") is an *object*, and one with a
property already suitable for this task:

Request.Querystring("val").Count

The .Count property will return 0 if the parameter is not present and 1 (or
more) if present.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Deepster | last post: by
2 posts views Thread by Imran Aziz | last post: by
2 posts views Thread by www.MessageMazes.com | last post: by
5 posts views Thread by Gary Wessle | last post: by
25 posts views Thread by pamelafluente | last post: by
2 posts views Thread by shapper | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.