c# - asp.net nested views with owns controllers -
i have target create nested architecture of view/controller. example: have few areas in webpage. areas managed own controller. in words need create independend pages , join them in 1 page. please see image:
so possible , can read it? thanks.
you can use @html.action()
render child views different controllers
public class firstcontroller : controller { public actionresult index() { return view(); } } public class secondcontroller : controller { [childactiononly] public actionresult method1() { return partialview(); } } public class thirdcontroller : controller { [childactiononly] public actionresult method2(int id) { return partialview(); } }
index view (firstcontroller)
.... @html.action("method1", "second") @html.action("method2", "third", new { id = somevalue })
you can use @{ html.renderaction();
more efficient generating lot of html.
Comments
Post a Comment