0
votes

I'm quite new to ASP.NET MVC, used to build WebForm using raw SQL...all EF, LINQ things just drive me crazy, lots to catch up...

Anyway, I have a homepage(index.cshtml) contains a caldendar, videos...lots of stuffs, I treat them all as widgets, planned to make them in seperate partial views. The index.cshtml has a _DefaultLayout.cshtml layout page so that I could insert the global menu there and automatically loads in every page, and I have the menu HTML in a partial view called _PVTopNav.cshtml, with a Nav Controller and Nav Model to get data from DB.

So...index -> _DefaultLayout(via _ViewStart) -> _PVTopNav

My question first is how do I initiate the Action in Nav Controller? Since the top most index HomeController won't include the Action to get menu data.

I read from the other post about RenderAction(), just don't know how to use it.

1

1 Answers

1
votes

In your View, you can use the Html.Action() helper to call any action in any controller. If the action result is a PartialViewResult it will render the html..

@Html.Action("actionName", "controllerName", "routeValues")