Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get post data for asp.net c# [duplicate]

<form action="test.aspx" method="post">
<input type"text" name="test[0].myitem" value="computer" />
<input type"text" name="test[0].quantity" value="1" />
<input type"text" name="test[0].price" value="US$10.5" />
<input type"text" name="test[1].myitem" value="printer" />
<input type"text" name="test[1].quantity" value="1" />
<input type"text" name="test[1].price" value="US$15.5" />
</form>

this it html source, How can I get and use this post data in asp.net c#

Request.Form["test"] and
Request.Form.getValues("test") didn't work.
Request.Form["test[0].myitem"] not work also

like image 648
user3444535 Avatar asked Apr 06 '14 07:04

user3444535


1 Answers

Try this

string[] keys = Request.Form.AllKeys;
var value = "";
for (int i= 0; i < keys.Length; i++) 
{
   // here you get the name eg test[0].quantity
   // keys[i];
   // to get the value you use
   value = Request.Form[keys[i]];
}
like image 148
Jaypal Avatar answered Oct 15 '22 19:10

Jaypal