Request to obtain the element values of the form with the same name attribute

Source: Internet
Author: User
Tags classic asp

HTML allows multiple elements with the same name attribute, for example

<Div>
<Input name = "txtname" id = "txtfirstname" type = "text"/>
<Input name = "txtname" id = "txtmiddlename" type = "text"/>
<Input name = "txtname" id = "txtlastname" type = "text"/>
</Div>
The common practice of server reading is:

String name = request. Params ["txtname"];

The result is a string separated by commas (,). You can manually split the string:
String [] nameparts = Name. Split (',');
However, when each input may contain commas (,), it is wrong to separate them by commas.
How can this problem be solved?
In classic ASP, you can obtain

<%
Firstname = request. Form ("txtname") (1)
Middlename = request. Form ("txtname") (2)
Lastname = request. Form ("txtname") (3)
%>
The use of classic ASP request is also supported in ASP. NET httprequest,

String [] nameparts = request. Params. getvalues ("txtname ");
String firstname = nameparts [0];
String middlename = nameparts [1];
String lastname = nameparts [2];
The above usage applies to get/post submission.

It is worth noting that the object used to store querystring/form/servervariables is system. collections. specialized. namevaluecollection, which is a key/value type object. Its particularity is that multiple values can be stored under a key.

Request to obtain the element values of the form with the same name attribute

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.