Using Form and QueryString collections

Source: Internet
Author: User
The full value provided when the user fills out the page <FORM> content, or the value that is entered after the URL in the browser's address bar, is used for ASP scripts through the FORM and QueryString collection. This is an easy way to access values in ASP code.


1, access to ASP collection of general technical


Most of the ASP sets are not much different from the common set that is seen in VB. In fact, they are arrays of values, but can be accessed by using a text string key (insensitive to size) and an integer index. So, if the client Web page contains <FORM> as follows:


<form action= "show_request.asp" method= "POST" >


firstname:<input type= "TEXT" name= "FirstName" >


lastname:<input type= "TEXT" name= "LastName" >


<input type= "SUBMIT" value= "Send" >


</FORM>


can access the values within its control by accessing the ASP's form collection:


strFirstName = Request.Form ("FirstName")


strLastName = Request.Form ("LastName")


You can also use the integer index of a control in a form, which starts with the first defined control in HTML, and then sorts the order by definition:


strFirstName = Request.Form (1)


strLastName = Request.Form (2)


However, such an integer-indexed technique is deprecated, because once a control in HTML has changed, or if a new control is inserted, the ASP code gets the wrong value. Further, it is very easy to confuse people who read the code.


1) To access the full value of the collection


can change a series of values on the entire form to a single character variable by referencing the collection without providing a key or index.


strallformcontent = Request.Form


If the text box contains values Priscilla and Descartes, the Request.Form statement returns the following characters:


firstname=priscilla&lastname=descartes


Note that the value provided is in the form of a name/value pair (that is, the control name = control value), and each pair of name/value is delimited by the symbol "&". This technique is useful if you intend to pass content from a form to an executable application or DLL in a standard format that you want to value. Generally, however, the contents of the collection are accessed by using the name of the control in the form as the text key.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.