MVC child - parent on the same page

I'm pretty new to using MVC3 so hopefully the terms I'm using are all correct.

Basically I'm looking for a way (if possible!) to have a parent and child(s) record be added on the same page. I'm able to get the page to display correctly, but I'm unsure how to update the parent model.

In my Create view I have all the fields for the parent, and I'd also like to add the child records to the form as well.

I'm currently using Html.RenderPartial("CreateChildView") to display my Create child page within the parent.

I'm also using Html.RenderPartial("IndexChildView) to display my child records that have been added.

Where I'm stuck at is how to update the Parent model from the "CreateChildView" from above, I've tried adding a submit button to the child view but I'm not getting the results I was hoping for.

the equivelent c# code that I'm kind of looking for is:

ParentObject.ChildObject.Add(new ChildObject)

and then a way to display this correctly

Thanks in Advance

Answers


Place both partials in div with ids. Post data with ajax from "CreateChildView" and update "IndexChildView" with response.


Need Your Help

Skip test method for specific type in generic test class

c# unit-testing generics nunit

I'm trying to unit test a part of a project; I'm using NUnit. The targeted unit processes objects of several types, all extending a base type. I've created a generic test class on which I set the d...

git checkout |TUTORIAL_JAVA_VERSION|

java git

I am following a tutorial to build an application based on Kurento (WebRTC media Server). Somewhere it is written: