QueryString

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 17
Reputation: daveyb91 is an unknown quantity at this point 
Solved Threads: 1
daveyb91 daveyb91 is offline Offline
Newbie Poster

QueryString

 
0
  #1
Aug 28th, 2009
Hello everyone,
Could someone please give me a good explanation about what I can do with it? I can't really find it on Google..
Thanks in advance,
Davey
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 185
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 24
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: QueryString

 
2
  #2
Aug 28th, 2009
I use querystring to retrieve parameters send from another form, let's say that you are and index.html and there is a link url to default.aspx like this
~/Default.aspx?var=hello

then and the Server code from Default.aspx to retrieve that value i have this.
  1. string stTest = Request.QueryString["var"];
now stTest is equal to "hello"
hope that help you
If your already resolved your issue, flag it as solved.
José Bisonó
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,187
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: QueryString

 
1
  #3
Aug 28th, 2009
Its handy if you want to pass data to other pages, especially when you want it retained in the browser's history. If you POST search terms to google for example then you wouldn't have a list of all searches you performed in your browser history.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 103
Reputation: cgeier is an unknown quantity at this point 
Solved Threads: 14
cgeier cgeier is offline Offline
Junior Poster

Re: QueryString

 
0
  #4
Aug 28th, 2009
It comes from the days of ASP.

The "Request.QueryString" command is used to collect values in a form with method="get".

SimpleForm_1.asp
  1. <form method="get" action="SimpleFormHandler_1.asp">
  2. <TEXTAREA NAME="location" COLS=33 ROWS=4></TEXTAREA>
  3. <input type='submit' value='Add Event'>
  4. </form>

SimpleFormHandler_1.asp
  1. <%@ Language=VBScript %>
  2.  
  3. <%
  4. Dim userLocation
  5.  
  6. 'location is the variable name as defined by "NAME="
  7. 'in SimpleForm_1.asp
  8. userLocation = Request.QueryString("location")
  9. %>

The "Request.Form" command is used to collect values in a form with method="post".

SimpleForm_2.asp
  1. <form method="post" action="SimpleFormHandler_2.asp">
  2. <TEXTAREA NAME="location" COLS=33 ROWS=4></TEXTAREA>
  3. <input type='submit' value='Add Event'>
  4. </form>

SimpleFormHandler_2.asp
  1. <%@ Language=VBScript %>
  2.  
  3. <%
  4. Dim userLocation
  5.  
  6. 'location is the variable name as defined by "NAME="
  7. 'in SimpleForm_2.asp
  8. userLocation = Request.form("location")
  9. %>


See http://www.w3schools.com/ASP/asp_inputforms.asp
Last edited by cgeier; Aug 28th, 2009 at 6:57 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 103
Reputation: cgeier is an unknown quantity at this point 
Solved Threads: 14
cgeier cgeier is offline Offline
Junior Poster

Re: QueryString

 
0
  #5
Aug 28th, 2009
You'll probably find more info on it if you search for "ASP Request.QueryString" and "ASP Request.Form".

C#
  1. string userLocation;
  2. userLocation = Request.QueryString["location"];


C#
  1. string userLocation;
  2. userLocation = Request.Form["location"];
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: QueryString

 
0
  #6
Aug 28th, 2009
this thread must be moved to ASP.NET forum.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: daveyb91 is an unknown quantity at this point 
Solved Threads: 1
daveyb91 daveyb91 is offline Offline
Newbie Poster

Re: QueryString

 
0
  #7
Aug 29th, 2009
Ok, I will flag this thread then.
Ok, so I read all of your comments, and thanks for it
I'm gonna ask another question about this.

I need to get the id=123 in http://www.website.com/something.php?id=123, in my C# application. Whenever I press a new button on the website the C# app needs to get the new id, or
value etc etc. So would this then be the best solution to get it? Or could I better use something else..?

Thanks again,
Davey
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: daveyb91 is an unknown quantity at this point 
Solved Threads: 1
daveyb91 daveyb91 is offline Offline
Newbie Poster

Re: QueryString

 
0
  #8
Aug 29th, 2009
And, I can't find the flag button
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,187
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: QueryString

 
0
  #9
Aug 29th, 2009
I flagged it for you. The button should be located under the reply:

sknake Online
Posting Virtuoso
Re: QueryString #9 1 Minute Ago | Add to sknake's Reputation | Flag Bad Post
Last edited by sknake; Aug 29th, 2009 at 10:38 am.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: daveyb91 is an unknown quantity at this point 
Solved Threads: 1
daveyb91 daveyb91 is offline Offline
Newbie Poster

Re: QueryString

 
0
  #10
Aug 29th, 2009
Oh yes, thanks haha.
How could I miss that?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC