Wednesday, 14 August 2013

Render partial view (with controller action) from another view

Render partial view (with controller action) from another view

I have a layout that contains a treeview. The treeview is populated by an
AddressBookController and rendered into every page with
@RenderPage("addressbook.cshtml") (it is currently in Shared). The problem
with this is that I have tight coupling between the View and the
Controller as in the top of my AddressBook.cshtml I have the following
code:
@{
var controller = new EstateManagerUI.Controllers.AddressBookController();
var topLevelFolder = controller.GetAddressBook(0);
}
How can I render the partial view FROM the controller so I can render it
like a normal view?

No comments:

Post a Comment