473,386 Members | 1,886 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,386 software developers and data experts.

How can I know the QueryString has a keyword or not?

ABC
How can I know the QueryString has a keyword or not?

For our case, the querystring sometime has only a keyword contains not any
value,

for example,

http://mysite.com/iijjkk.aspx?added

I want to know the querystring has 'added' keyword or not.
Apr 8 '06 #1
5 1509
"ABC" <ab*@abc.com> wrote in news:Of**************@TK2MSFTNGP05.phx.gbl:
http://mysite.com/iijjkk.aspx?added

I want to know the querystring has 'added' keyword or not.


From within an ASP page, just use Request.QueryString:

string k = Request.QueryString["added"];

If the parameter was there, k will be non-null.
--
Klaus H. Probst, MVP
http://www.simulplex.net/

Apr 8 '06 #2
Hi,

Request.QueryString collection itself isn't probably populated if there
isn't both key abd value (.aspx?key=value) but you should be able to inspect
the qs as normal string.

For example

Dim hasKey As Boolean = (Request.QueryString.ToString().IndexOf("key") > -1)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"ABC" <ab*@abc.com> wrote in message
news:Of**************@TK2MSFTNGP05.phx.gbl...
How can I know the QueryString has a keyword or not?

For our case, the querystring sometime has only a keyword contains not any
value,

for example,

http://mysite.com/iijjkk.aspx?added

I want to know the querystring has 'added' keyword or not.

Apr 8 '06 #3
Teemu Keiski wrote:
Hi,

Request.QueryString collection itself isn't probably populated if
there isn't both key abd value (.aspx?key=value) but you should be
able to inspect the qs as normal string.

For example

Dim hasKey As Boolean =
(Request.QueryString.ToString().IndexOf("key") > -1)


Most of the time, this will be correct, but you may get false hits with this
method.

For instance, when checking for the key "ID", this querystring will
erroneously satisfy your condition:
www.domain.com/index.aspx?name=didi

--

Riki
Apr 8 '06 #4
or

If Request.Params.GetKey("KeyName") Is Nothing Then

Response.Write("The key 'KeyName' does not exist")

End If
--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net

"Klaus H. Probst" <us*******@simulplex.net> wrote in message
news:Xn**********************************@207.46.2 48.16...
"ABC" <ab*@abc.com> wrote in news:Of**************@TK2MSFTNGP05.phx.gbl:
http://mysite.com/iijjkk.aspx?added

I want to know the querystring has 'added' keyword or not.


From within an ASP page, just use Request.QueryString:

string k = Request.QueryString["added"];

If the parameter was there, k will be non-null.
--
Klaus H. Probst, MVP
http://www.simulplex.net/

Apr 8 '06 #5
Certainly,

just note my response in light of the original question...

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Riki" <ri**@dontnagme.com> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Teemu Keiski wrote:
Hi,

Request.QueryString collection itself isn't probably populated if
there isn't both key abd value (.aspx?key=value) but you should be
able to inspect the qs as normal string.

For example

Dim hasKey As Boolean =
(Request.QueryString.ToString().IndexOf("key") > -1)


Most of the time, this will be correct, but you may get false hits with
this method.

For instance, when checking for the key "ID", this querystring will
erroneously satisfy your condition:
www.domain.com/index.aspx?name=didi

--

Riki

Apr 8 '06 #6

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

Similar topics

3
by: Arpan | last post by:
A link has the following URL: <a href="Page1.asp?cname=<%= Request.QueryString("cname") %>&cadd1=<%= Request.QueryString("cadd1") %>&cadd2=<%= Request.QueryString("cadd2") %>&cplace=<%=...
4
by: Apple Plexy | last post by:
tearing my hair out here..., I am creating a site to show artists work. I have a database and can retrieve and display a list of artisits, other info, and a related image for each artist - all...
1
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:...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
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 ... ...
3
by: Dan Sikorsky | last post by:
How can I get the Querystring passed to the Referring Page from its referrer? I don't want the querystring coming to my current page. I want the querystring that came to the referring page, so...
3
by: Nick | last post by:
I've created a user control that extracts data from a database. The VB code is all contained in a code-behind file. I'm trying to extract a value from the request.querystring but keep getting...
11
by: Fabio | last post by:
I know the syntax for variable "variabletopass" in ASP: www.destinationpage.asp?variable=<%=variabletopass%> What's the syntax for Javascript? Thks
3
by: pingsheng | last post by:
Dear all, I have a form with dynamically created input fields. These fields go to next page for submitting into SQL database. The thing is all fields are the same but 4 fields. So each record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.