
QueryString | 349
HttpRequest
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
QueryString
NameValueCollection = Request.QueryString
The QueryString collection returns an instance of the NameValueCollection class
containing all the keys and values passed as a part of the query string (typically by
submitting an HTML form that uses the GET method instead of POST).
Parameters
NameValueCollection
An Object variable of type NameValueCollection.
Example
The example writes the contents of the QueryString collection to the browser:
Sub Page_Load( )
Dim Counter1, Counter2 As Integer
Dim Keys(), subKeys( ) As String
Dim QSColl As NameValueCollection
' Load QS into NameValueCollection
QSColl=Request.QueryString
' Get keys into an array
Keys = QSColl.AllKeys
For Counter1 = 0 To Keys.GetUpperBound(0)
Message.Text &= "Key: " & Keys(Counter1) & "<br/>"
subKeys = QSCol1.GetValues(Counter1) 'Get all values under this key
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 (note that the form
method attribute has been set to GET, which is required for the form value to be
sent as part of the query string):
<html>
<head>
<title>Submit a named parameter via ...