查找主视图什么ASP.NET MVC控制器 [英] Find what ASP.NET MVC controller in master view

查看:105
本文介绍了查找主视图什么ASP.NET MVC控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的所有其他视图共享的主视图。这是在该主视图我显示菜单。现在我需要找出在目前这样我就可以禁止我什么控制器/启用某些菜单选项。

I have a shared master view for all my other views. It's in this master view I show the menu. Now I need to find out in what controller I'm currently in so I can disable/enable certain menu options.

例如,它应该是可能的preSS的富链接,如果我在富控制器的电流。

For example it should be possible to press the "foo" link if I'm current in the "foo" controller.

我怎样才能做到这一点?

How Can I do this?

推荐答案

您能不能用?

<%=Html.ViewContext.RouteData.GetRequiredString("controller") %>

善良,

这篇关于查找主视图什么ASP.NET MVC控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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