Comprehensive, categorized, searchable collection of links to ASP & ASP.NET resources...
ASP.NET Directory

Applications
Assembly & Controls
Books & Media
Community
Other ASP.NET Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

ASP Directory

Applications
ASP.NET Directory
Books & Media
Community
Components
Other ASP Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

Newsgroups

Participate in over
100 ASP & ASP.NET related newsgroups right here @ Fuzzy Software...

.NET Framework
- .net.faqs
- .net.framework
- .net.general
- .net.setup
- .net.scripting
- .net.xml

Web Services
- aspnet.webservices
- msdn.soaptoolkit
- msdn.webservices

SQL Server
- sqlserver.setup
- sqlserver.prog...
- sqlserver.tools

Classic ASP
- asp.db
- asp.general
- asp.components

Scripting
- scripting.jscript
- scripting.remote
- scripting.vbscript
- scripting.wsh

All newsgroups...

ASP Built-in
Objects Reference


Application Object
ObjectContext Object
Request Object
Response Object
Server Object
Session Object

Personalise Fuzzy
Make Homepage
Link To Fuzzy
Bookmark This Page

Add our directory to your site in less than
2 minutes...



ASP.NET Chart and Charting for .NET








Whats New!
The Form collection retrieves the values of form elements posted to the HTTP request body by a form using the POST method.

Syntax

Request.Form(element)[(index)|.Count] 
 

Parameters

element
Specifies the name of the form element from which the collection is to retrieve values.
index
An optional parameter that enables you to access one of multiple values for a parameter. It can be any integer in the range 1 to Request.Form(parameter).Count.

Remarks

mugen battery Samsung Galaxy Nexus au

The Form collection is indexed by the names of the parameters in the request body. The value of Request.Form(element) is an array of all of the values of element that occur in the request body. You can determine the number of values of a parameter by calling Request.Form(element).Count. If a parameter does not have multiple values associated with it, the count is 1. If the parameter is not found, the count is 0.

To reference a single value of a form element that has multiple values, you must specify a value for index. The index parameter may be any number between 1 and Request.Form(element).Count. If you reference one of multiple form parameters without specifying a value for index, the data is returned as a comma-delimited string.

When you use parameters with Request.Form, the Web server parses the HTTP request body and returns the specified data. If your application requires unparsed data from the form, you can access it by calling Request.Form without any parameters.

You can use an iterator to loop through all the data values in a form request. For example, if a user filled out a form by specifying two values, Chocolate and Butterscotch, for the FavoriteFlavor parameter, you could retrieve those values by using the following script.

<%
For Each item In Request.Form("FavoriteFlavor")
  Response.Write item & "<BR>"
Next
%>
 

The preceding script would display the following.

Chocolate
Butterscotch
 

The same output can be generated with a For...Next loop, as shown in the following script.

<%
For i = 1 To Request.Form("FavoriteFlavor").Count
  Response.Write Request.Form("FavoriteFlavor")(i) & "<BR>"
Next
%>
 

You can use this iterator to display the parameter name, as shown in the following script.

<% For Each x In Request.Form %>
Request.Form( <%= x %> ) = <%= Request.Form(x) %> <BR>
<% Next %>
 

This script displays the following on the browser.

FavoriteFlavor = Chocolate
FavoriteFlavor = Butterscotch
 

Example

Consider the following form.

<FORM ACTION = "/scripts/submit.asp" METHOD = "post">
<P>Your first name: <INPUT NAME = "firstname" SIZE = 48>
<P>What is your favorite ice cream flavor: <SELECT NAME = "flavor">
<OPTION>Vanilla 
<OPTION>Strawberry 
<OPTION>Chocolate 
<OPTION>Rocky Road</SELECT>
<p><INPUT TYPE = SUBMIT>
</FORM>
 

From that form, the following request body might be sent.

firstname=James&flavor=Rocky+Road
 

The following script can then be used.

Welcome,  <%= Request.Form("firstname") %>. 
Your favorite flavor is <%= Request.Form("flavor") %>.
 

The following output is the result.

Welcome, James. Your favorite flavor is Rocky Road.
 

If the following script is used

The unparsed form data is:  <%= Request.Form %> 
 

the output would be

The unparsed form data is:  firstname=James&flavor=Rocky+Road
 

Applies To

Request Object

See Also

ClientCertificate, Form, QueryString, ServerVariables






$10/mo & 3 Months FREE!


Receive all the latest quality ASP
& ASP.NET content direct to your inbox. Sign-up to our newsletter.






DevDirect.com - Tools and Components for Software Developers

Dotnetjohn.com

DevBuilder.org

ChrisShell.com

More partners...

.net CART ASP.NET Shopping Cart and Ecommerce Solution for .NET
  9969 ASP & ASP.NET resources in over 483 categories and growing daily...
Fuzzy Software - asp / asp.net resources, tutorials, code, scripts, applications, components, newsgroups, hosts and much more... Sitemap 0 1 4