Name
Params
Synopsis
NameValueCollection = Request.Params
The
Params collection returns an
instance of the NameValueCollection
class
containing key/value pairs for the QueryString, Form,
ServerVariables, and Cookies collections. You can use the Params
collection to dump all of these collections to a file or to the
browser and to troubleshoot an application or track the form values
your application receives, regardless of whether they come via GET
(QueryString collection) or POST (Form collection).
Parameters
-
NameValueCollection
An Object variable of type NameValueCollection.
Example
The example writes the keys and values contained in the Params collection to the browser:
Sub Page_Load( ) Dim Counter1, Counter2 As Integer Dim Keys(), subKeys( ) As String Dim ParamColl As NameValueCollection ' Load Params into NameValueCollection ParamColl=Request.Params ' Get keys into an array Keys = ParamColl.AllKeys For Counter1 = 0 To Keys.GetUpperBound(0) Message.Text &= "Key: " & Keys(Counter1) & "<br/>" ' Get all values under this key subKeys = ParamColl.GetValues(Counter1) For Counter2 = 0 To subKeys.GetUpperBound(0) Message.Text &= "Value " & CStr(Counter2) & ": " & _ subKeys(Counter2) & "<br/>" Next Counter2 Message.Text &= "<br/>" Next Counter1 End Sub
The following code can be used to post to the example page:
<html> <head> <title>Submit a named parameter via POST</title> </head> <body> <form id="form1" action="Params.aspx" method="POST"> <h3>Name:</h3> <input type="text" name="name"> <input ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.