Simple way to make a string out of Request.Form

C

crossoft

Is there a quick way to get all the params and values from the
Request.Form object in ASP.NET?

"If Only it were this simple" Code:
Dim s As String = Request.Form.ToString()

Then s would for example become

id=3&name=Joe+Smith&view=32&page=1&count=1502

Anyone know how to do that? Thanks.
 
J

Juan T. Llibre

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
 
C

crossoft

Thanks Juan,

I guess it was wishful thinking on my part that there was some
undocumented method of the Form class that dumped it all out. Your
code is almost verbatim what I've been having to do.

If only we could inherit from the Form class to add our own
capabilities!

Your fellow Wrox Author - Christopher L. Miller
 
J

Juan T. Llibre

Hey, Chris!
Long time no hear from you!

re:
code is almost verbatim what I've been having to do.

Yup...it's just about the only way to get at that.

re:
If only we could inherit from the Form class
to add our own capabilities!

That'd be nice...

re:
Your fellow Wrox Author

We had the best of times with the "old" Wrox, didn't we ?

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top