473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 23401
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Deepster | last post by:
Hi Guys Here is what I am doing ... Have a page default.asp which looks at the url and checks for querystring's. if there are none passed goes to a function. if there are particular querystrings...
2
by: Imran Aziz | last post by:
Hello All, I have ASP.net , C# pages checking for query string variables, the old ASP has a count property that one could check for each key/value pair to determine if it is available in the query...
2
by: www.MessageMazes.com | last post by:
Greetings, I'm experimenting with an ASP page that reads data from a file name that is passed to it as a parameter, as in this page, which works, because the "good" file exists. ...
5
by: Gary Wessle | last post by:
hi or is there a better way to check the existence of "py" in a string "s"? string s = "djrfpyfd"; string t = "py"; string r = s.substr(s.find("py"),2); cout << (t==r) << endl;
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
2
by: shapper | last post by:
Hello, How can I check if a parameter, for example "name", is available in a QueryString? I need to create a default value if the parameter is not available. Thanks, Miguel
10
by: Dieter Pelz | last post by:
Hallo, what is the best way to check the installation of mfc80 and vcrt sidebyside assemblies? Best Regards, Dieter Pelz
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
2
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.