943,557 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1245
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 28th, 2009
0

QueryString

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
daveyb91 is offline Offline
20 posts
since Aug 2009
Aug 28th, 2009
2

Re: QueryString

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.
ASP.NET Syntax (Toggle Plain Text)
  1. string stTest = Request.QueryString["var"];
now stTest is equal to "hello"
hope that help you
Reputation Points: 56
Solved Threads: 56
Posting Pro in Training
jbisono is offline Offline
431 posts
since May 2009
Aug 28th, 2009
1

Re: QueryString

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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 28th, 2009
0

Re: QueryString

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
ASP.NET Syntax (Toggle Plain Text)
  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
ASP.NET Syntax (Toggle Plain Text)
  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
ASP.NET Syntax (Toggle Plain Text)
  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
ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 41
Solved Threads: 15
Junior Poster
cgeier is offline Offline
104 posts
since Oct 2008
Aug 28th, 2009
0

Re: QueryString

You'll probably find more info on it if you search for "ASP Request.QueryString" and "ASP Request.Form".

C#
ASP.NET Syntax (Toggle Plain Text)
  1. string userLocation;
  2. userLocation = Request.QueryString["location"];


C#
ASP.NET Syntax (Toggle Plain Text)
  1. string userLocation;
  2. userLocation = Request.Form["location"];
Reputation Points: 41
Solved Threads: 15
Junior Poster
cgeier is offline Offline
104 posts
since Oct 2008
Aug 28th, 2009
0

Re: QueryString

this thread must be moved to ASP.NET forum.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Aug 29th, 2009
0

Re: QueryString

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
daveyb91 is offline Offline
20 posts
since Aug 2009
Aug 29th, 2009
0

Re: QueryString

And, I can't find the flag button
Reputation Points: 10
Solved Threads: 1
Newbie Poster
daveyb91 is offline Offline
20 posts
since Aug 2009
Aug 29th, 2009
0

Re: QueryString

I flagged it for you. The button should be located under the reply:

Quote ...
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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 29th, 2009
0

Re: QueryString

Oh yes, thanks haha.
How could I miss that?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
daveyb91 is offline Offline
20 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Lock Window
Next Thread in ASP.NET Forum Timeline: i want to write the byte[] array into a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC