Reputation:
I have a view which contains multiple partial views, each of which is collecting information to populate different entity objects. My question is, upon the POST, how do I get a collection of objects that are populated with the right properties as a parameter to the Controller POST handler method?
so I would like something like this:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(List<object> objectCollection)
{
}
Upvotes: 1
Views: 3269
Reputation: 6000
Use FormCollection e.g...
public ActionResult Create(FormCollection frm)
{
Book book = new Book();
book.Name = frm["Name"];
// other work
return View();
}
Upvotes: 1
Reputation: 47647
You got various options. Common one is to use default model binder. You just need to follow some naming (of html input elements) rules.
Advanced options are to use ActionFilters and custom model binders.
I recommend you to read this and this article.
Upvotes: 3