MVC哪里渲染菜单视图 [英] MVC where to render menu view

查看:123
本文介绍了MVC哪里渲染菜单视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里就是我想要做的:

在一个页面上,我将有一个LeftMenu这将是独立的页面,以及RightMenu这将取决于用户当前的页面上。

On a page, I would have a LeftMenu that would be independent of the page, and a RightMenu that would depend on the page the user is currently on.

我想使用MVC从asp.net。我可以使用的RenderPartial渲染菜单,但是,从另一方面,视图真的不应该处理这 - 所以在我看来,我想比MVC更多的WinForms。

I want to use MVC from asp.net. I could use RenderPartial to render the menus but on the other hand, the View shouldn't really handle this - so it seems to me that I'm thinking more WinForms than MVC.

加上RightMenu必须知道什么是为了显示根据上下文正确的菜单项当前显示的那么一点点。

Plus the RightMenu would have to know a little bit about what is displayed currently in order to display the correct menu items based on context.

你会如何处理这种情况。也是讲这个的所有链接将会大大AP preciated。

How would you handle this situation. Also any links that talk about this would be greatly appreciated.

修改:当我说的视图不应该处理这个我在每个视图思维的RenderPartial的,而且是有点讨厌 - 我猜的母版的方法,然后每个控制器把什么东西在视图模型从而使RightMenu就知道渲染可能是什么,我在寻找什么。

EDIT When I said that the View shouldn't handle this I was thinking of RenderPartial in every view and that was kinda nasty - I guess the masterpage approach and then every controller putting something in the ViewModel so that the RightMenu would know what to render might be what I'm looking for .

推荐答案

您最好的选择将是把母版页菜单,并指定该母版页的任何意见要求的菜单。

Your best bet would be to put the menu in a master page and assign that master page to whatever views require the menu.

这篇关于MVC哪里渲染菜单视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆