How can I get data from dynamic generated controls

2019-08-31 17:57发布

问题:

I want to generate a couple of checkboxes on an ASP .NET MVC page. How can I retrieve their data in a controller after posting the page?

回答1:

Use the Request.Form collection:

Request.Form["control-id"]

or declare a FormsCollection parameter in your action method and use it to retrieve the value.