Using asp.net mvc3 and jquery
I have x number of forms on a page, each created when a user adds a new item. Each form represents a model in c#. Each form has a list of strings as one of the properties. I want to have a save all button that submits all of the forms, but I would like to serialize them into one list of objects before I do so, and then sort it out in the back end. How can I do this with jQuery?
<form>
<input name="ListThing" value="one" />
<input name="ListThing" value="two" />
<input name="ListThing" value="three" />
<input name="Name" value="Bob" />
</form>
<form>
<input name="ListThing" value="one" />
<input name="ListThing" value="two" />
<input name="ListThing" value="three" />
<input name="Name" value="Pat" />
</form>
c#
public class myModel{
public List<string> ListThing {get; set;}
public string Name {get; set;}
}
controller - UploadController -action
[HttpPost]
public ActionResult SaveAll( List<myModel> myModels )
{
// do stuff
return View();
}