Omu
Omu

Reputation: 71288

asp.net mvc view of a controller inside of a view of an other controller

so i have a "Parents" controller with list and edit view for it (to view add/edit/delete parents)

and a "Children" controller same thing (view list add/edit/delete children)

and now i need to refactor; to put the children view inside the parent view, so that when you edit a parent you can see the list of his children and edit/delte/add some children

what's the best way to do that in asp.net mvc, is there any patterns for that or something


i tried to use RenderAction() and it works fine it shows the list of users, but the problem is that you click the edit button for a users -> edit some data -> click save and you return not to the parent edit view with the list of users but just to the list of users view

Upvotes: 1

Views: 381

Answers (1)

skalb
skalb

Reputation: 5567

You should create a Partial View that is strongly typed to your Children's Class.

Then include that on your Parent's page using HTML.RenderPartial().

This can be updated using AJAX, if needed.

Upvotes: 1

Related Questions