473,396 Members | 1,689 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.

Get a querystring key name

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[0], Request.QueryString.Key[0], and nothing
is returning the value to me. I've driven down several levels into the
debugger and found the value (nested several object hierarchy levels deep)
but can't figure out how to get access to it.

Help?
Nov 23 '05 #1
5 2754
Request.QueryString(0).Name
".NET Developer" <a@b.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
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[0], Request.QueryString.Key[0], and
nothing is returning the value to me. I've driven down several levels into
the debugger and found the value (nested several object hierarchy levels
deep) but can't figure out how to get access to it.

Help?

Nov 23 '05 #2
Nope...doesn't work (at least not in asp.net 1.1)

I found something that seems to work for now:

Request.Url.Query.Replace("?","");

Gets me what I need - just doesn't seem like the "right' way to get it.

"Scott M." <s-***@nospam.nospam> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Request.QueryString(0).Name
".NET Developer" <a@b.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
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[0], Request.QueryString.Key[0], and
nothing is returning the value to me. I've driven down several levels
into the debugger and found the value (nested several object hierarchy
levels deep) but can't figure out how to get access to it.

Help?


Nov 23 '05 #3
You can use GetKey for that. Here's some code. Let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

Try
' Make sure you pass everything such as
' ?mykey=4
Response.Write(Request.QueryString.GetKey(0))
Catch exc As Exception
Response.Write(exc.Message)
End Try

".NET Developer" <a@b.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
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[0], Request.QueryString.Key[0], and
nothing is returning the value to me. I've driven down several levels into
the debugger and found the value (nested several object hierarchy levels
deep) but can't figure out how to get access to it.

Help?


Nov 23 '05 #4
Well, you see, that's part of the problem I have to solve - I can't
guarantee the key will have "=[value]" after it. Which causes GetKey(0) to
fail.

Don't you think ?mykey should make GetKey(0) contain "mykey" ? Seems logical
to me. I don't think keys should be dependent on associated values.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:Ok**************@TK2MSFTNGP14.phx.gbl...
You can use GetKey for that. Here's some code. Let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

Try
' Make sure you pass everything such as
' ?mykey=4
Response.Write(Request.QueryString.GetKey(0))
Catch exc As Exception
Response.Write(exc.Message)
End Try

".NET Developer" <a@b.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
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[0], Request.QueryString.Key[0], and
nothing is returning the value to me. I've driven down several levels
into the debugger and found the value (nested several object hierarchy
levels deep) but can't figure out how to get access to it.

Help?

Nov 23 '05 #5
if (this.Request.QueryString.AllKeys.Length == 1)

{

string keyName = this.Request.QueryString[0];

}

HTH,

g

".NET Developer" <a@b.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
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[0], Request.QueryString.Key[0], and
nothing is returning the value to me. I've driven down several levels into
the debugger and found the value (nested several object hierarchy levels
deep) but can't figure out how to get access to it.

Help?

Dec 19 '05 #6

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

Similar topics

3
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
0
by: scott | last post by:
Below, I'm trying to remove the querystring name& value of "catID=12". I mananged to isolate the RESULTS part, but I need to be able to strip the querystring name and it's value, no matter if the...
5
by: Arpan | last post by:
An ASP application retrieves records from a SQL Server database. In the first page of the application, the user has to enter a password & the columns retrieved from the DB table depends upon the...
3
by: MikeR | last post by:
Hello - I pass an item to an asp page as a query string. The value has a space in it. On the receiving page, the value displays fine just as a variable, but if I use it to pre-fill an input box,...
3
by: Jon | last post by:
Hi, I have hyperlink objects in a datagrid that redirect the user back to the current page with this syntax: <a href="mypage.aspx?id=foo"> When the page reloads, code in Page_Load then takes...
4
by: Mark Goldin | last post by:
How can I pull data on the server from QueryString? In classic ASP I do Request.QueryString("valuename"). What about doing something like this in ASP.NET? Thanks
4
by: Raterus | last post by:
Howdy, Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to...
4
by: | last post by:
Hi all, If I am reading this right, then the querystring parameters must be "&amp;" and not "&". However, IIS 6.0 and asp.net request.querystring fails to capture the values if "&amp;" is specified....
3
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" &...
1
by: beebee | last post by:
Hi all. I am having a bit of difficulty: Here is what is happening: I have an application that spits out a thankyou.aspx page and i would like to pass it the querystring values it had collected...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.