Wednesday, 14 August 2013

ASP.NET Model binding One to Many + AJAX

ASP.NET Model binding One to Many + AJAX

I have a model with a one-to-many relationship kinda similar to this:
public class people
{
public int id { get; set; }
public sting name { get; set; }
public virtual stuff things { get; set; }
}
public class stuff
{
public int id { get; set; }
public string name { get; set; }
public int thingType { get; set; }
}
I now need to be able to create and edit "stuff" for the person I am
currently editing on my "editPeople" page. I'm using AJAX to create JQuery
UI Dialog box for the stuff edit/create form, and then I post it back to
the server to create a bunch of hidden fields so I can actually save this
data later.
I'm concerned that these hidden fields would be named in a way that such
that when I post my peopleEdit back to the controller, the Model binding
won't properly convert the "stuff" that I have created/edited. Am I doing
this wrong/Is there a better method? Am I forced into creating a custom
model binder?

No comments:

Post a Comment