MVC where to display menu view

here is what I am trying to do:

On the page, I will have a LeftMenu, which is independent of the page, and a RightMenu, which will depend on the page the user is currently on.

I want to use MVC from asp.net. I could use RenderPartial to render the menu, but on the other hand the View shouldn't be able to handle it, so it seems to me that I think more WinForms than MVC.

Plus RightMenu had to learn a little about what is currently being displayed in order to display the correct menu items based on context.

How would you handle this situation. Any links that talk about this would also be appreciated.

EDIT When I said the View shouldn't handle this, I thought about RenderPartial in all views and it was disgusting - I think the main page approach and then each controller puts something in the ViewModel so RightMenu would know what to do, maybe what i'm looking for.

0


source to share


4 answers


It is best to place the menu on a home page and assign that home page to whatever you want to view.



+1


source


In the early days of MVC CTP, we discussed this in detail.

I don't believe that the controller should stuff all kinds of multiple unrelated data (into its task), in the ViewModel to control the menu.

One of the early suggestions was to just use AJAX to call another action on the controller to get the menu data, I think that was terrible.



I haven't worked with MVC since the CTP days, but I believe there was a trade-off called RenderAction that allows the View (or main page) to call the controller and spawn a partial view.

This is an area where the MVC idea really breaks down because you start getting too much logic in your view.

+1


source


In the left menu, place it on the master page and use a partial (custom control for it).

On the right menu, look at the RenderAction HtmlHelper extension. This allows you to partially view your own controller and return ViewData independently of the main controller. Alternatively, you can pass data from the main ViewData of the view to the action method to customize the data displayed.

0


source


Suppose tiles like borders where you can split the left side which has the menu and the right side which has the body. So when you create the template, use the right side of the insert page that is independently loaded. You can search [ http://tiles.apache.org/index.html] [[1 ]

-1


source







All Articles