
Form | 345
HttpRequest
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
It is not necessary to use the HtmlInputFile control to upload files that can be
retrieved via the Files collection. As long as the submitting page uses the POST
method and the
multipart/form-data enctype attribute, you can use the standard
HTML file input tags:
<input type="file" id="myFile" name="myFile">
Note the use of the name attribute, without which the files collection will not
contain the uploaded file for the control.
Form
NameValueCollection = Request.Form
The Form collection returns an instance of the NameValueCollection class
containing all form fields passed along with an HTTP POST request. This collec-
tion will contain data only when the Content-Type of the HTTP request is either
application/x-www-form-urlencoded or multipart/form-data.
The Form collection is one of two ways to retrieve data, depending on the HTTP
method used to submit the data. The Form collection retrieves data submitted by
an HTML form whose method attribute is set to POST, while the QueryString collec-
tion (covered later in this section) retrieves values submitted by HTML forms
whose
method attribute is set to GET.
Parameter
NameValueCollection
An Object variable of type NameValueCollection.
Example
The example demonstrates how ASP.NET allows a single page to be used to
submit values ...