|
-
Jun 18th, 2003, 07:28 AM
#1
Thread Starter
PowerPoster
Getting Posted Variables
Hi, I have a weform that gets data from the user... i then Post the data to the next page which processes it and enters it into the database.
How do i get the values of the variables that were posted to the next page?
In PHP you simply put
$Title = $_POST[txtTitle]
In ASP i have no clue 
Thanks!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 18th, 2003, 10:25 AM
#2
PowerPoster
I am not sure how to get posted variables, but I use Request.QueryString for query string values. Maybe what you are looking for is in the Request object.
-
Jun 18th, 2003, 11:12 AM
#3
Thread Starter
PowerPoster
What do you mean by query string values?
I just want to get the values of the textboxes on the last page that were posted to the next page.
For example i have a form tag
VB Code:
<form name="form" action="addnews2.aspx" method="post">
'and inside that form i have 2 text fields
<input id="txtTitle" type="text" maxLength="75" size="50" name="txtTitle" runat="server">
<input id="txtNews" type="text" maxLength="75" size="50" name="txtTitle" runat="server">
'then i have a submit button
<input onmousedown="Validate()" type="submit" value="Add News" name="Submit">
</form>
So when someone clicks the Add News button it Posts the info in those text boxes to the server and goes to the next page addnews2.aspx. Now i want to get the values of those textboxes and use them in addnews2.aspx.
Am i going about thsi the wrong way? That's how it's done in PHP, i assumed that's how it was done in ASP too..
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 19th, 2003, 12:15 PM
#4
PowerPoster
http://msdn.microsoft.com/library/de...sformtopic.asp
You need the HttpRequest.Form method to return a NameValueCollection that contains your data.
-
Jun 19th, 2003, 02:15 PM
#5
Thread Starter
PowerPoster
Thanks, I went to the page and tried the code but as usual it doesn't work, msdn code never seems to work.
VB Code:
Dim loop1 As Integer
Dim arr1() As String
Dim coll As NameValueCollection
' Load Form variables into NameValueCollection variable.
coll = Request.Form
' Get names of all forms into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBound(0)
Response.Write("Form: " & arr1(loop1) & "<br>")
Next loop1
I assume i need to import some class or something becasue it is saying the NameValueCollection type is not defined..
I also tried using the HttpRequest.Form thing and got basically the same thing.
Anyone have a working example?
Thanks!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 19th, 2003, 02:39 PM
#6
Request.form("txtTitle") is the same thing as $_POST[txtTitle]
in PHP.
-
Jun 19th, 2003, 04:16 PM
#7
Thread Starter
PowerPoster
Ahh cool deal. Works great! Thanks!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 19th, 2003, 05:21 PM
#8
PowerPoster
The above code works, you just have to import System.Collections.Specialized
If you ever have a problem like that again, where it says NameValueCollection isn't defined, just do a search on the object in the msdn library, you will find its object tree to refer to what to import.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|