I am creating an ASP.NET application that allows the user to add form elements to a page within a form. When the page is posted (via the submit button) I need to loop through ALL the posted values in the form and get the values.
I can't check for specific values as I don't know how many there will be or what they will be called.
Could someone point me in the right direction of getting ALL posted values so I can loop through them?
p.s I was looking in Request.Form but couldn't see anything obvious to use.
Thanks.
The Request.Form property returns a NameValueCollection you can iterate over:
foreach (string name in Request.Form.AllKeys) {
string value = Request.Form[name];
// Do something with (name, value).
}
foreach (string key in Request.Form)
{
var value = Request.Form[key];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With