asp.net.ph

Request.Form Property

System.Web Namespace   HttpRequest Class


Returns a collection of form variables.

Syntax


Script [ NameValueCollection variable = ] Request.Form

Property Value


variable Returns a NameValueCollection representing a collection of form variables.

The property is read only with no default value.

Remarks

Request.Form returns a collection of name/value pairs representing the elements of a client form submitted via the POST method. This collection is populated when the HTTP request Content-Type is either

  • multipart/form-data, or
  • application/x-www-form-urlencoded.

To obtain the value of a single form input element, use

Request.Form[ "controlName" ]
  C# VB

To obtain the name and value pair of each form input element, you can loop thru the collection using a simple foreach statement.


foreach ( string var in Request.Form ) {
   Response.Write ( Request.Form[ var ] );
}
  C# VB

Example

The following example [ C# ] shows how you can dynamically retrieve ( and display into an HTML table ) the name and value pair of each form input element passed from a client via a POST method.

<table class="data" width="90%">
<tr>
  <th>Name</th>
  <th>Value</th></tr>

<% string val;
  foreach ( string name in Request.Form ) {
     If ( Request.Form[ name ] != "" ) val = Request.Form[ name ];
     else val = "&nbsp;"; %>
<tr>
  <td><%= name %></td>
  <td><%= val %></td></tr>
<% } %>
</table>

 Show me 

See Also

HttpRequest Members   Request.QueryString Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph