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