473,407 Members | 2,359 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,407 software developers and data experts.

QueryString Exists!

Can some one tell me how on earth i find out whether a querystring exists.
In classic asp I would do the following.

If(Request.QueryString("test").Count = 0) The Response.Write("QueryString
does not exist!")

Cheers,
Adam
Nov 19 '05 #1
5 6320
There's 2 ways that I use, depending on the circumstances: (this is C#)

1) If you just want to know if it exists:
if (Request.QueryString["xxxx"] != null)
{
// it exists
}
else
{
// it doesn't
}

2) If you want to do something with it during the same test:
int parameterValue = 0;
try
{
parameterValue = Convert.ToInt32(Request.QueryString["xxxx"]);
}
catch
{
// doesn't exist, or wasn't a number
}

"Adam Knight" <de*@brightidea.com.au> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Can some one tell me how on earth i find out whether a querystring
exists.
In classic asp I would do the following.

If(Request.QueryString("test").Count = 0) The Response.Write("QueryString
does not exist!")

Cheers,
Adam

Nov 19 '05 #2
Hi Adam,

I always do the following:

If (Request("test") = Nothing) Then
Response.Write("QueryString does not exist!")
Else
End If

That will get you started. There is probably a good reason not to do it
that way but I don't know what it is off the top of my head. Someone will
let us know. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"Adam Knight" <de*@brightidea.com.au> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Can some one tell me how on earth i find out whether a querystring exists. In classic asp I would do the following.

If(Request.QueryString("test").Count = 0) The Response.Write("QueryString
does not exist!")

Cheers,
Adam

Nov 19 '05 #3
Wouldn't that be IS Nothing? I thought there was a really good reason
not to use equals with Nothing.

Nov 19 '05 #4
If Request.Params("test") Is Nothing Then
label1.text = "QueryString does not exist!"
End if
Nov 19 '05 #5
Hi Phillip,

You are right, definitely use Is instead of =. I remember reading something
about not using Request() in place of Request.QueryString() but it was long
ago and I don't remember what the reasoning was. Maybe it only applied to
old ASP and not ASP.Net. Either way, good catch! Ken.

"Phillip Ian" <ph****@comcast.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Wouldn't that be IS Nothing? I thought there was a really good reason
not to use equals with Nothing.

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Keith | last post by:
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.
4
by: Steve | last post by:
Hi All, This problem is really annoying me, as I am sure there is a simple solution to it. If I try to read a querystring value in the Page_Load event and that querystring does not exist I...
1
by: Mark | last post by:
Hello Can anyone tell me how to check if a a querystring is present or not I.E. If request.querystring("key") is in the url or not because when i try to reference it in anyway and its not...
12
by: Alex | last post by:
I have a question about determining if one QueryString keys exists. The idea is, if this key exists, than its presence is enough to indicate that its value is true. For example ... ...
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: Chris Ashley | last post by:
My app seems to lose its viewstate completely when I modify the querystring. Anything I can do about this? Cheers, Chris
6
by: Helter Skelter | last post by:
hi, i want to have a querystring in a webpage. i dont mind what it does (i just want to experiment with it). how do i get the asp.net page to do something when i type in a querystring? if you...
3
by: Dariusz Tomon | last post by:
Hi My problem is like that: I'm trying to pass values branza and jezyk in querysting: http://localhost/euroadres/pokazbranza.aspx?branza=transport lotniczy&jezyk=1 Branza is type...
2
by: Carlos | last post by:
Hi all, I would like to have a page that checks for an optional parameter being passed. I use the request.querystring("myvar") when the parameter is being passed, but when the parameter is...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.