1

I am using ASP.NET MVC4. I have different types of users, (let's say Type1 and Type2), which will have different menus. Therefore, I entered at the master site, something like the following

  <% if (Page.User.IsInRole("TypeA")){%>

             <li><%: Html.ActionLink("Test1", "Test1", "Test")%></li>
             <li><%: Html.ActionLink("Test2", "Test2", "Test")%></li>
                            <%} 
                              else{%>
             <li><%: Html.ActionLink("Test3", "Test3", "Test")%></li>
             <li><%: Html.ActionLink("Test4", "Test4", "Test")%></li>

                            <%
                            }

I do not know if that is the best way to do it, but this was what I thought (If there is any better or professional way to do this, please suggest it to me).

The problem now, is that If userA is logged in, then how I can highlight the page Test1 if he is at Test1,and how do I highlight the page Test2 if he is at Test2 at the menu?

I mean, if I had the menu code at each page, this is easy. But how I can do that when the menu is at the Site Master?

I cannot come up with any practical, or nice solution on that...

Is there a way to do that?

Jim Blum
  • 2,656
  • 5
  • 28
  • 37
  • 1
    If you are using `MVC4` then how this has come `<% %>` – Nilesh Gajare Jan 16 '14 at 11:17
  • @Nilesh I am using aspx view engine, not razor – Jim Blum Jan 16 '14 at 11:18
  • @Kobi. You are possibly right Kobi. Thanks a lot for informing me. I will study that page, which looks promising, and if it can also help me, I will remove this question. – Jim Blum Jan 16 '14 at 11:25
  • @Jim - No problem. You [don't have to remove the question](http://meta.stackoverflow.com/help/duplicates), by the way, it's perfectly OK. I wanted to post an answer, but a comment in my code pointed me to the other question - I took it from there (I also wrote extension for main/sub menus, and Areas). Good luck! – Kobi Jan 16 '14 at 12:52

0 Answers0