2
I have a list of inputs that are automatically generated by script and they are inserted in a form thus staying:
<input type="text" id="txtValue" name="txtValue" />
<input type="text" id="txtValue" name="txtValue" />
<input type="text" id="txtValue" name="txtValue" />
...
These are not elements manipulated by the C# code-Behind (Asp.NET Wenforms application), and I need to get these values in back-end when doing the form post.
How then to capture these values?
It is possible, for example, to work with these values in the form of a vector?
Obs: When analyzing the Request.Form
I found that only one txtValue element appeared.
Your answer is correct but it is a mistake to have more than one element with the same
id
, theid
of an element must be unique on the page, for those cases where multiple fields with the same name must be used the attributename
ofinput
– Leandro Godoy Rosa
In this case it can, since it doesn’t seem to me to be used for anything, simply by changing
id
forname
solves the problem, theRequest.Form["txtValue"]
should work normally, and even in tests I have done here using only theid
I couldn’t get the values, only when I switched toname
that worked, and I tested on IE, Chrome, Firefox and Opera 12 having the same result on all– Leandro Godoy Rosa