Retrieve all posted values in ASP.NET

后端 未结 2 401
闹比i
闹比i 2021-01-04 20:04

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 throug

相关标签:
2条回答
  • 2021-01-04 20:40
        foreach (string key in Request.Form)
        {
            var value = Request.Form[key];
        }
    
    0 讨论(0)
  • 2021-01-04 20:43

    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).
    }
    
    0 讨论(0)
提交回复
热议问题