I have been trying to find a way to access a master page control in order to show/hide a menu option.
In my MP, I have:
<div id="menucontainer">
<ul id="menu">
<li id="menuHome"><%= Html.ActionLink("Home", "Index", "Home")%></li>
<li id="menuNewHire"><%= Html.ActionLink("New Hire", "Index", "newHire")%></li>
<li><%= Html.ActionLink("Software", "Index", "Software")%></li>
<li><%= Html.ActionLink("Hardware", "Index", "Hardware")%></li>
<li><%= Html.ActionLink("Telecom", "Index", "Telecom")%></li>
<li><%= Html.ActionLink("About", "About", "Home")%> </li>
Then a ContentPlaceHolder after that..What I want to do is in the controller, see if a user is in a certain AD group, if so, show or hide one of the menu options. In this case, mnuNewHire I only want to be visible to certain users.
Any ideas on how to do this? Thanks in advance for any and all help.
Geo…
I would externalize this menu into a separate controller and use Html.Action helper method. So for example you could have a model:
then a controller:
and a corresponding partial view:
and finally in your master page: