Skip to main content

Posts

Showing posts from June, 2015

Post dictionary parameters or IEnumerable parameters to MVC controller

I found a very good artical about how to pass the dictionary or IEnumerable<T> parameters to MVC controller . http://www.hanselman.com/blog/ ASPNETWireFormatForModelBindingToArraysListsCollectionsDicti onaries.aspx So if your action requires array of objects, say Person: public ActionResult ProcessAction(Person[] people) Then your MVC view HTML should look like: < input type = "text" name = "people[0].FirstName" value = "George" /> < input type = "text" name = "people[0].LastName" value = "Washington" /> < input type = "text" name = "people[1].FirstName" value = "Abraham" /> < input type = "text" name = "people[1].LastName" value = "Lincoln" /> < input type = "text" name = "people[3].FirstName" value = "Thomas" /> < input type = "text" name = ...