ASP   «Prev  Next»

Lesson 5Request.Form
ObjectiveDescribe how the Request object processes HTML Form data.

ASP Request.Form

Form elements in HTML (text and password input areas, check boxes, radio buttons, and dropdown lists) allow the user to submit a variety of data to the server. But now what? The server needs to read, store, and process this information. The Request.Form version of the Request object can do this.

Reading form data

The following code segment shows part of an HTML input form, specifically a text box containing the user's name:

<INPUT TYPE="TEXT" NAME="Name" SIZE="25" VALUE="Enter your name">

The ASP Form collection allows you to reference this and other data contained in the form. Since the text box form element is named Name, you would reference it as Form("Name"). To write this piece of data back to the browser, you only need to write the ASP code:

<%=Request.Form("Name") %> 

For some form elements (such as <SELECT> or check boxes), you can choose more than one item.
That's not difficult in ASP, because you can specify an index for the Form collection and access one value at a time.
If you don't specify an index, you get a comma-separated list of all the element values. The next lesson describes passing user data in a URL request.

ASP Request Form - Exercise

Click the Exercise link below to use ASP to read and write HTML Form data.
ASP Request Form - Exercise