I have data posted with my <input type="submit" value ="submit"> which has the following format (checked with firebug)
Role1 true
Role1 false
Role1 true
Role1 false
Name1 "Name 1"
Name2 "Name2"
and in my controller
[HttpPost]
public ActionResult GetPostData(ArrayList data)
the issue is what kind of parameters should i put in the controller to be able to have some kind of data structure which gets filled up with the values sent by post? I don’t want to use FormCollection. I can make some sort of a PostModel, but all these data is sent through hidden fields dynamically generated with jquery in most of the time so I cannot imagine how I can bind the postmodel with the fields.
I guess you meant (as having Role1 four times seems a bit weird):
You could use a view model:
and then:
And since I suspect you are doing checkboxes stuff (due to the double boolean value for each role as the CheckBox helper generates a hidden field), here’s what I will suggest you:
Model:
Controller:
View:
or even better, using an editor template which will be rendered for each role:
and the editor template (
~/Views/Shared/EditorTemplates/RoleViewModel.cshtml):