473,811 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpRequest.Par ams in C# : Get Value of Key

I am attempting to fetch the value of a paramter passed in on the http
request url. Example:

http://localhost.mypage.aspx?ID=12345

In the URL above I am wanting to retrieve the value of the key ID.
When I execute the code below I am getting the entire URL and not just
the value of the key ID. Any suggestions?

string idValue = Request.Params. Get("ID");

Thanks...Kevin
Nov 18 '05 #1
2 18104
Use the querystring
<%
Response.Write( Request.QuerySt ring["ID"]);
// Below line outputs same but works for arrays of same named params
Response.Write( Request.QuerySt ring.GetValues( "ID")[0]);
%>

or in VB.NET
<%
Response.Write( Request.QuerySt ring("ID"))
Response.Write( Request.QuerySt ring.GetValues( "ID")(0))
%>

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------

"Kevin" <br*****@hotmai l.com> wrote in message
news:ea******** *************** ***@posting.goo gle.com...
I am attempting to fetch the value of a paramter passed in on the http
request url. Example:

http://localhost.mypage.aspx?ID=12345

In the URL above I am wanting to retrieve the value of the key ID.
When I execute the code below I am getting the entire URL and not just
the value of the key ID. Any suggestions?

string idValue = Request.Params. Get("ID");

Thanks...Kevin

Nov 18 '05 #2
Just try using

string idValue = Request["ID"] for C#
or
string idValue = Request("ID") for VB.NET

That way you dont have to worry bout whether the param was passed using
query string or as a part of post.

Regards,

Hermit Dave

"Kevin" <br*****@hotmai l.com> wrote in message
news:ea******** *************** ***@posting.goo gle.com...
I am attempting to fetch the value of a paramter passed in on the http
request url. Example:

http://localhost.mypage.aspx?ID=12345

In the URL above I am wanting to retrieve the value of the key ID.
When I execute the code below I am getting the entire URL and not just
the value of the key ID. Any suggestions?

string idValue = Request.Params. Get("ID");

Thanks...Kevin

Nov 18 '05 #3

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

Similar topics

3
4641
by: HikksNotAtHome | last post by:
In Mozilla 1.4b, when the URL is set to a local URL, it works as expected. function showIt(){ var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "blank.html" ,true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.myForm.outputSource.value = xmlhttp.responseText; } }
3
3001
by: MuZZy | last post by:
Hello, I am developing a web application. If i call an aspx page with several parameters, is there a way to get access to parameter values by key? I am using C# E.g. void PageLoad(object sender, EventArgs e) { string album = Request.<???>("album");
3
1655
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into the first index? I have worked around this by getting the MethodInfo via reflection and invoking it there. Is there a simpler way? Thanks, Stan
11
15898
by: Keith Patrick | last post by:
Could someone explain to me the relationship between these two classes? I am ripping my hair out trying to divert an HttpRequest to a new location via an HttpWebRequest, but I cannot get my session xfer to work, possibly due to the cookies not being compatible. I've spent over a week trying to get the HWR to integrate nicely with my app, but I cannot get the session to transfer, and it'd probably take me even longer if I tried to digest...
6
2572
by: Praveen | last post by:
As you all know the value of input, checkbox and other "user editable" elements can be retrieved on postback via Request.Params list, if you know their ID. However, if there is a span element (for example) whose value gets updated via javascript when the user does something, that value is not made available as part of the Request.Params list. Persumably because "span" is not considered a "editable" element and it's value is not sent...
1
2027
by: Gunnar | last post by:
I am finding some unusual behavior with techniques I am using to show/hide/update data without having to refresh the page. I'm quite sure it's developer ignorance on my part and would be grateful for any suggestions. My page has 10 tables with their visibility controlled by the user making a menu selection. For example, selecting menu_1 calls a function which displays table_1 by setting table_1's style display: block and hides tables...
1
8129
by: samtilden | last post by:
I want to print out some tracing messages from Global.asax.cs/Application_BeginRequest(). I easily got: System.Web.HttpContext.Current.Request.RawUrl, and System.Web.HttpContext.Current.Request.Params. I would now like to get the entire:
3
2502
by: Daniel | last post by:
Hi all, I am using .NET 1.1. I have a form with a cancel button, something like this: <form method="post"....> <input type="submit" value="Submit"> <input type="submit" value="Cancel" id="btnCancel"> </form>
9
1639
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
Given a method like void F ( params object args ) { ... } I had always _assumed_ that args would never be null, but now it's been brought to my attention that if the caller uses F ( null ) then args _will_ be null because the compiler can implicitly convert the
0
9605
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
10651
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...
1
10403
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5555
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...
1
4341
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
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
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.