473,808 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

QueryString keys

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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null, QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no value assigned to it. Any ideas?

Thanks,

Alex
Nov 18 '05 #1
12 5295
Private Function KeyInQuery(ByVa l Key As String) As Boolean
Dim keyName As String
Dim val As String

For i As Integer = 0 To Request.QuerySt ring.Count - 1
val = Request.QuerySt ring.Item(i)

If Not val Is Nothing AndAlso val.ToLower() = Key.ToLower()
Return True
End If
Next

Return False
End Function

Try the above function :)

Mythran
"Alex" <al**@nospam.ne t> wrote in message
news:u0******** ******@TK2MSFTN GP10.phx.gbl...
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that
client exists, so its value is true. In the code behind, I can tell that client
exists using Request.QuerySt ring.Keys.Count , which equals 1.
QueryString["client"] is null, QueryString.Key s[0] is null,
QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no
value assigned to it. Any ideas?

Thanks,

Alex

Nov 18 '05 #2
I'm not sure I understand what the dilema is. If you can tell from Keys.Count
= 1 that the querystring has atleast one key and you can reference
QueryString["Client"] and determine if it is null or not then what is the
problem?

Besides, what good is a QueryString key with no value?

I think somehow your approach to produce a solution is flawed. Perhaps, more
information about what it is you are actually trying to accomplish? A little
more of a bigger picture?

-Demetri

"Alex" wrote:
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null, QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no value assigned to it. Any ideas?

Thanks,

Alex

Nov 18 '05 #3
> Besides, what good is a QueryString key with no value?

I think he said he wants to use the key as a boolean flag. I've ran into
this myself before. Seems silly to pass a qs like client=true or
client=false, or client=1 and client=0, etc. When just passing client by
itself could represent "true" and no qs could represent "false".

my .02
Greg
"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
I'm not sure I understand what the dilema is. If you can tell from
Keys.Count
= 1 that the querystring has atleast one key and you can reference
QueryString["Client"] and determine if it is null or not then what is the
problem?

Besides, what good is a QueryString key with no value?

I think somehow your approach to produce a solution is flawed. Perhaps,
more
information about what it is you are actually trying to accomplish? A
little
more of a bigger picture?

-Demetri

"Alex" wrote:
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me
that client exists, so its value is true. In the code behind, I can tell
that client exists using Request.QuerySt ring.Keys.Count , which equals 1.
QueryString["client"] is null, QueryString.Key s[0] is null,
QueryString.Key s["client"] is null, Request.QuerySt ingText = "client",
ect.

I cannot seem to find a way to determine if a QuerySting exists when it
has no value assigned to it. Any ideas?

Thanks,

Alex

Nov 18 '05 #4
Won't

if IsNull(Request. QueryString("Cl ient")) then
Return False
end if

Work?
"Mythran" wrote:
Private Function KeyInQuery(ByVa l Key As String) As Boolean
Dim keyName As String
Dim val As String

For i As Integer = 0 To Request.QuerySt ring.Count - 1
val = Request.QuerySt ring.Item(i)

If Not val Is Nothing AndAlso val.ToLower() = Key.ToLower()
Return True
End If
Next

Return False
End Function

Try the above function :)

Mythran
"Alex" <al**@nospam.ne t> wrote in message
news:u0******** ******@TK2MSFTN GP10.phx.gbl...
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that
client exists, so its value is true. In the code behind, I can tell that client
exists using Request.QuerySt ring.Keys.Count , which equals 1.
QueryString["client"] is null, QueryString.Key s[0] is null,
QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no
value assigned to it. Any ideas?

Thanks,

Alex

Nov 18 '05 #5
Greg,

That is exactly what my aim is. Thanks for your input.

Akex

--
Alex Mueller
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Besides, what good is a QueryString key with no value?


I think he said he wants to use the key as a boolean flag. I've ran into
this myself before. Seems silly to pass a qs like client=true or
client=false, or client=1 and client=0, etc. When just passing client by
itself could represent "true" and no qs could represent "false".

my .02
Greg
"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
I'm not sure I understand what the dilema is. If you can tell from
Keys.Count
= 1 that the querystring has atleast one key and you can reference
QueryString["Client"] and determine if it is null or not then what is the problem?

Besides, what good is a QueryString key with no value?

I think somehow your approach to produce a solution is flawed. Perhaps,
more
information about what it is you are actually trying to accomplish? A
little
more of a bigger picture?

-Demetri

"Alex" wrote:
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me
that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null,
QueryString.Key s["client"] is null, Request.QuerySt ingText = "client",
ect.

I cannot seem to find a way to determine if a QuerySting exists when it
has no value assigned to it. Any ideas?

Thanks,

Alex


Nov 18 '05 #6
Ok, just for this scenario, the only QueryString key on the url is client, as in www...com/main.aspx?client. QueryString["client"] will return null. QueryString.Key s.Count will return 1. I have no way of telling that the QS client is present b/c it does not have a value assigned to it. I could write a function to search parts of the url, but I wanted to see if any answers would surface first.

I do not have a QueryString.Ite m in C#. I do have other name value collections, but none of them work for me as I reported in the original post. Any more ideas?

Thanks

Alex
"Mythran" <ki********@hot mail.com> wrote in message news:OM******** ******@TK2MSFTN GP10.phx.gbl...
Private Function KeyInQuery(ByVa l Key As String) As Boolean
Dim keyName As String
Dim val As String

For i As Integer = 0 To Request.QuerySt ring.Count - 1
val = Request.QuerySt ring.Item(i)

If Not val Is Nothing AndAlso val.ToLower() = Key.ToLower()
Return True
End If
Next

Return False
End Function

Try the above function :)

Mythran
"Alex" <al**@nospam.ne t> wrote in message news:u0******** ******@TK2MSFTN GP10.phx.gbl...
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null, QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no value assigned to it. Any ideas?

Thanks,

Alex
Nov 18 '05 #7
Request.QuerySt ring.ToString() will return "Client"

Perhaps, you can split the querystring into a string array variable and do a
foreach on the string array and test for the string "Client" to see if it
exist.

-Demetri

"Alex" wrote:
Greg,

That is exactly what my aim is. Thanks for your input.

Akex

--
Alex Mueller
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Besides, what good is a QueryString key with no value?


I think he said he wants to use the key as a boolean flag. I've ran into
this myself before. Seems silly to pass a qs like client=true or
client=false, or client=1 and client=0, etc. When just passing client by
itself could represent "true" and no qs could represent "false".

my .02
Greg
"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
I'm not sure I understand what the dilema is. If you can tell from
Keys.Count
= 1 that the querystring has atleast one key and you can reference
QueryString["Client"] and determine if it is null or not then what is the problem?

Besides, what good is a QueryString key with no value?

I think somehow your approach to produce a solution is flawed. Perhaps,
more
information about what it is you are actually trying to accomplish? A
little
more of a bigger picture?

-Demetri

"Alex" wrote:

> 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 ...
>
> www.something.com/main.aspx?client
>
> Client is the QueryString, but no value is given. This would mean to me
> that client exists, so its value is true. In the code behind, I can tell> that client exists using Request.QuerySt ring.Keys.Count , which equals 1.> QueryString["client"] is null, QueryString.Key s[0] is null,
> QueryString.Key s["client"] is null, Request.QuerySt ingText = "client",
> ect.
>
> I cannot seem to find a way to determine if a QuerySting exists when it
> has no value assigned to it. Any ideas?
>
> Thanks,
>
> Alex



Nov 18 '05 #8
QueryString("cl ient") does indeed return a value of Nothing (in VB), so that won't help you. But you can search to see if the key exists in the collection...

This should work. BTW, it is essential the same as Mythran posted previously.

Dim found As Boolean = False
For i As Integer = 0 To Request.QuerySt ring.Count - 1
If Request.QuerySt ring(i).ToLower = "client" Then
found = True
Exit For
End If
Next

Greg

"Alex" <al**@nospam.ne t> wrote in message news:uQ******** ******@TK2MSFTN GP12.phx.gbl...
Ok, just for this scenario, the only QueryString key on the url is client, as in www...com/main.aspx?client. QueryString["client"] will return null. QueryString.Key s.Count will return 1. I have no way of telling that the QS client is present b/c it does not have a value assigned to it. I could write a function to search parts of the url, but I wanted to see if any answers would surface first.

I do not have a QueryString.Ite m in C#. I do have other name value collections, but none of them work for me as I reported in the original post. Any more ideas?

Thanks

Alex
"Mythran" <ki********@hot mail.com> wrote in message news:OM******** ******@TK2MSFTN GP10.phx.gbl...
Private Function KeyInQuery(ByVa l Key As String) As Boolean
Dim keyName As String
Dim val As String

For i As Integer = 0 To Request.QuerySt ring.Count - 1
val = Request.QuerySt ring.Item(i)

If Not val Is Nothing AndAlso val.ToLower() = Key.ToLower()
Return True
End If
Next

Return False
End Function

Try the above function :)

Mythran
"Alex" <al**@nospam.ne t> wrote in message news:u0******** ******@TK2MSFTN GP10.phx.gbl...
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null, QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no value assigned to it. Any ideas?

Thanks,

Alex
Nov 18 '05 #9
the problem you have is the query string is not well formed, the "=" is required by the w3c standard for it to be a valid url. but all is not lost, try

Page.Request.Se rverVariables["QUERY_STRI NG"]

this will return the raw querystring

-- bruce (sqlwork.com)
"Alex" <al**@nospam.ne t> wrote in message news:u0******** ******@TK2MSFTN GP10.phx.gbl...
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 ...

www.something.com/main.aspx?client

Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QuerySt ring.Keys.Count , which equals 1. QueryString["client"] is null, QueryString.Key s[0] is null, QueryString.Key s["client"] is null, Request.QuerySt ingText = "client", ect.

I cannot seem to find a way to determine if a QuerySting exists when it has no value assigned to it. Any ideas?

Thanks,

Alex
Nov 18 '05 #10

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

Similar topics

3
3262
by: spradl | last post by:
Anyone have a VB function or know how to retrieve original querystring values after they have been decryted and lie within a string? For example: Say I have the querystring "id=99&page=5&value=&info=true" which has been encrypted, sent as one querystring "encryptedstring=blahblahblah", and then decrypted back into the original string "id=99&page=5&value=&info=true". How do I get those querystring values associated back with the string...
1
6753
by: lion | last post by:
my Problem: a query string passed into a html page doesn't display correctly on a mac I am just using html and javascript (no ASP, PHP or server side scripting) This is the query string: popup.html?pImage=30_leilani_dowding_b_060.jpg&ordRef=1000&Title=Leilani&nbsp;Dowding using the QueryString function below, the pImage variable should be
2
315
by: Hazzard | last post by:
I am trying to figure out how to add an additional value to a querystring collection so that when I click on a datagrid cell, there will be a key to distinguish it from another column's functionality. I have Edit and Delete columns that each contain the ColumnID for the record I want to either edit, or delete. When I pull the item of the collection on the target page's page_load event, I will be able to either invoke a delete or an edit...
9
6033
by: Doug | last post by:
I need to do the following... FOR myitem IN Request.Querystring 'get the key 'get the value NEXT What do I DIM myitem as? DictionaryEntry doesn't work...or do I have to loop through it by index and get the key then the item out of the query string...
5
10994
by: VB Programmer | last post by:
I have an ASPX page that is used for content. I have a master page which sticks the page in an IFrame. Question: From the content/ASPX page, I can't seem to reference request.querystring. Any way around this? I need to read it. Thanks!
5
2772
by: .NET Developer | last post by:
Ok, this is probably simple but it's been driving me nuts. If I have a URL like this: http://www.mysite.com/MyPage.aspx?MyKey What code would I write to get that value "MyKey" out of the querystring? Without the = and a value after it, is it considered a querystring value still? I've tried Request.Params, Request.QueryString.Key, and nothing is returning the value to me. I've driven down several levels into the debugger and found the...
10
7575
by: VB Programmer | last post by:
If I have a url like this: www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye, in VB.NET, how do I get the "mypage.aspx?myvalue1=hello&myvalue2=goodbye" portion? Thanks!
3
1394
by: Rob | last post by:
Hi all, I've encrypted an entire querystring, thus the keys and values, at the moment I do only have one key and one value in it, so I could write something specific for that key, but I know as soon as I do I'll need to use more and then I'll be back here again... So...lets assume I have this: ?uid=1234&dept=23
12
14884
by: Peter | last post by:
Hi if I have a url/query like "localhost?a&b&c=123" then I thought I could get these parameters and values by using NameValueCollection query = HttpContext.Current.Request.QueryString; But if I then try "query.AllKeys" I only get two keys, namely "null" and "c". Is this correct behaviour? Are "a" and "b" considered to be values for
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10628
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.