Sideway
output.to from Sideway
Draft for Information Only

Content

Request Object
 Request.Form Collection
   Syntax:
   Parameters:
   Remarks:
  Examples:

Request Object

The main function of Request object is the retrieving of HTTP request variables from the client.

Request.Form Collection

Request.Form Collection retrieves the element values of a form which is sent in the body of HTTP request with a form using the POST method.

Syntax:

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

 Or in an ASP file. Imply

<% Request.Form(element)[(index)|.Count] %>

Parameters:

element

The parameter "element" is the name of the form element in the form collection to be retrieved. The data type of "element" is string and is enclosed by quotation marks (" ").

index

The optional parameter "index" is the number of the index of a form element with multiple values in the form collection to be retrieved. The data type of "index" is an integer and the range is from 1 to  Request.Form(element).Count

.Count

The parameter "Count" is the optional information of the parameter "element" with delimeter ".". The parameter "Count" is a read-only attribute to return the total number of the available values of the parameter " element".

Remarks:

The HTTP form collection is the string posted to the HTTP request body with a form using the POST method.

Although HTTP form collections are usually generated by a response page output, HTTP form collection are only strings contained in an request headers. The values of HTTP form collection can also be generated by any user. Therefore header data or user input should be encoded or be validated before using.

The Form Collection is indexed by the names of the parameter elements in the request body. With the Request.Form Collection, the value of form element can be retrieved by name.

For element with multiple values, the value of Request.Form(element) will be in form of an array of all values of the element in the Form Collection. And the number of multiple values of the element can be obtained by  Request.Form(element).Count. For single value varible,  Request.Form(element).Count equal to 1. If the variable does not exist,   Request.Form(element).Count equal to 0.

And therefore the multiple values of a variable can be referenced by the parameter "index",  Response.Form(element)(index). and the range of the index is from 1 to  Response.Form(element).Count.

However, if the index is not specified for a multiple values element, the Request.Form(element) will return all values in the form of comma-delimited string.

Besides, if there is no specified element for the Request.Form(), the Request.Form() will return the unparsed Form Collection data. But when post data more than 100KB, the Request.Form cannot be used. And should be rewritten by using the Request.Binary Read method.

Since the multiple values of a element is in the form of an array, the values of the element can be retrieved using a for index loop or a for each element loop.  And for the name of the form element, a for each element loop should be used.

Examples:

  • HTTP form submit

    ASP script command:

    <% ... Request.Form ... %>
    <form action="http://127.0.0.1/form.asp" method="post">
    A:<input name="A" value="9" size="4" />  and
    B:<input name="B" value="1" size="4" /> plus <input name="B" value="2" size="4" />
    <input type="SUBMIT" />
    </form>

    HTML web page ouput (Layout):

    A: and B: plus

    HTTP Request:

    http://127.0.0.1/form.asp

    HTTP Request Body:

    A=9&B=1&B=2

    CMD commands: 

    telnet 127.0.0.1 80 (CR)
    Post /form.asp HTTP/1.1 (CR)
    Host: 127.0.0.1 (CR)
    Connection: keep-alive (CR)
    Content-Type: application/x-www-form-urlencoded(CR)
    Content-Length: 11(CR)
     (CR)

    (... Response ...)
    HTTP/1.1 100 Continue
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET 

    A=9&B=1&B=2

    (... Response ...)

  • With no variable specified in Request.Form

    ASP script command:

    <%= Request.Form %>

    HTTP response output (Buffered):

    A=9&B=1&B=2

    HTML web page ouput:

    A=9&B=1&B=2

  • With variable A specified in Request.Form

    ASP script command:

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

    HTTP response output (Buffered):

    9

    HTML web page ouput:

    9

  • With variable B specified in Request.Form

    ASP script command:

    <%= Request.QueryString("B") %>

    HTTP response output (Buffered):

    1, 2

    HTML web page ouput:

    1, 2

  • With variable B specified in Request.Form().Count

    ASP script command:

    <%= Request.Form("B").Count %>

    HTTP response output (Buffered):

    2

    HTML web page ouput:

    2

  • Loop for all values in variable B specified in Request.Form() by count

    ASP script command:

    <%
    For i=1 to Request.Form("B").count
    Response.Write Request.Form("B")(i) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2

  • Loop for all values in variable B specified in Request.Form() by item

    ASP script command:

    <%
    For Each item in Request.Form("B")
    Response.Write (item) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2

  • Loop for all form elements in the form by item

    ASP script command:

    <%
    For Each item in Request.Form
    Response.Write (item) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    A<br />
    B<br />

    HTML web page ouput:

    A
    B


©sideway

ID: 120200018 Last Updated: 2/7/2012 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339new

Travel 7new

Reference 79

Computer

Hardware 251

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 431

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019