QueryString键 [英] QueryString keys

查看:59
本文介绍了QueryString键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于确定是否存在一个QueryString密钥的问题。这个想法是,如果这个密钥存在,那么它的存在就足以表明它的值是真的。例如......

www.something.com /main.aspx?client


客户端是QueryString,但没有给出值。这对我来说意味着客户存在,所以它的价值是真的。在后面的代码中,我可以告诉客户端存在使用Request.QueryString.Keys.Count,等于1.QueryString [" client"]为null,QueryString.Keys [0]为null,QueryString.Keys [" client" ;]为null,Request.QueryStingText =" client"等。


我似乎找不到一种方法来确定QuerySting是否存在没有分配给它的值。任何想法?


谢谢,


Alex

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.QueryString.Keys.Count, which equals 1. QueryString["client"] is null, QueryString.Keys[0] is null, QueryString.Keys["client"] is null, Request.QueryStingText = "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

推荐答案

私有函数KeyInQuery(ByVal Key As String)As Boolean

Dim keyName As String

Dim val As String


For i As Integer = 0 To Request.QueryString.Count - 1

val = Request.QueryString.Item(i)


如果不是val则没有,也是val。 ToLower()= Key.ToLower()

返回True

结束如果

下一页


返回错误

结束功能


尝试以上功能:)


Mythran

Alex <人** @ nospam.net>写在消息

新闻:u0 ************** @ TK2MSFTNGP10.phx.gbl ...

我有一个关于确定是否存在一个QueryString密钥。如果这个密钥存在,那么想法

,它的存在足以表明它的值是

true。例如......

www.something.com /main.aspx?client


客户端是QueryString,但没有给出值。这对我来说意味着

客户端存在,所以它的值是真的。在后面的代码中,我可以使用Request.QueryString.Keys.Count告诉客户端

,它等于1.

QueryString [" client"]为null, QueryString.Keys [0]为null,

QueryString.Keys [" client"]为null,Request.QueryStingText =" client"等等。

当我没有分配给它的

值时,我似乎找不到确定QuerySting是否存在的方法。任何想法?


谢谢,


Alex

Private Function KeyInQuery(ByVal Key As String) As Boolean
Dim keyName As String
Dim val As String

For i As Integer = 0 To Request.QueryString.Count - 1
val = Request.QueryString.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.net> wrote in message
news:u0**************@TK2MSFTNGP10.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.QueryString.Keys.Count, which equals 1.
QueryString["client"] is null, QueryString.Keys[0] is null,
QueryString.Keys["client"] is null, Request.QueryStingText = "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


I 我不确定我是否理解这个困境是什么。如果您可以从Keys.Count告诉

= 1,查询字符串至少有一个密钥,您可以参考

QueryString [" Client"]并确定它是否为null或者不是什么是

问题?


此外,没有价值的QueryString密钥有什么用呢?


我认为你的方法产生解决方案是有缺陷的。或许,更多关于你实际上想要实现的目标的信息?一点点

更大的图片?


-Demetri


" Alex"写道:
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:
我有一个关于确定是否存在一个QueryString键的问题。这个想法是,如果这个密钥存在,那么它的存在就足以表明它的值是真的。例如......

www.something.com /main.aspx?client

客户端是QueryString,但没有给出值。这对我来说意味着客户存在,所以它的价值是真的。在后面的代码中,我可以告诉客户端存在使用Request.QueryString.Keys.Count,等于1.QueryString [" client"]为null,QueryString.Keys [0]为null,QueryString.Keys [" client" ;]是null,Request.QueryStingText =" client"等等。

我似乎无法找到一种方法来确定QuerySting是否存在没有分配给它的值。任何想法?

谢谢,
Alex
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.QueryString.Keys.Count, which equals 1. QueryString["client"] is null, QueryString.Keys[0] is null, QueryString.Keys["client"] is null, Request.QueryStingText = "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



>除此之外,没有值的QueryString键有什么用?


我认为他说他想把密钥用作布尔标志。我以前自己遇到了这个问题。似乎愚蠢地传递一个qs,比如client = true或

client = false,或者client = 1和client = 0等等。当只是通过客户端传递

本身就可以代表"真"并且没有qs可以代表假。


我的.02

格雷格

" Demetri" <德***** @ discussions.microsoft.com>在消息中写道

news:61 ********************************** @ microsof t.com ...
> 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*****@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
我不确定我理解困境是什么。如果你能从Keys.Count
= 1判断出查询字符串至少有一个密钥你可以参考查询字符串[" Client"]并确定它是否为null然后是什么问题是什么呢?

此外,没有价值的QueryString密钥有什么用呢?

我认为你生产解决方案的方法存在缺陷。也许,
更多关于你实际想要实现的目标的信息?一个更大的图片

-Demetri

Alex写道:
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:
我有一个关于确定是否存在一个QueryString键的问题。
的想法是,如果这个密钥存在,那么它的存在足以表明它的值是真的。例如......

www.something.com /main.aspx?client

客户端是QueryString,但没有给出值。这对我来说意味着客户存在,所以它的价值是真实的。在后面的代码中,我可以告诉
客户端存在使用Request.QueryString.Keys.Count,它等于1.
QueryString [" client"]为null,QueryString.Keys [0]为null , QueryString.Keys [" client"]为null,Request.QueryStingText =" client",


我似乎无法找到确定是否如果没有为其分配值,则存在QuerySting。有什么想法吗?

谢谢,
Alex
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.QueryString.Keys.Count, which equals 1.
QueryString["client"] is null, QueryString.Keys[0] is null,
QueryString.Keys["client"] is null, Request.QueryStingText = "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



这篇关于QueryString键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆