Solved

Hide a tab in MVC

Posted on 2012-04-05
3
676 Views
Last Modified: 2012-04-06
I just created a vanilla "MVC 3" application in VS 2010.

How can I hide the "Home" tab programmatically when the "view" loads?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Assisted Solution

by:ambience
ambience earned 450 total points
ID: 37815620
By default the Home tab is in the _Layout.cshtml in the Shared views folder. One possible way to hide it is shown below.

            <div id="logindisplay">
                @Html.Partial("_LogOnPartial", Session["user"])
            </div>
            <ul id="menu">
@if (Session["EnableHomeTab"] != null)
{
               <li>@Html.ActionLink("Home", "Index", "Home")</li>
}
               <li>@Html.ActionLink("File Browser", "Index", "FileBrowser")</li>
                <li>@Html.ActionLink("Settings", "Index", "Settings")</li>
            </ul>

Then whenever you want to enable Home tab just add a key "EnableHomeTab" to session object

Session["EnableHomeTab"] = true;

to disable it again

Session.Remove("EnableHomeTab");
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 50 total points
ID: 37815802
Tom,

If you aren't familiar with MVC 3 yet, I would assume that you are using the Razor view engine, rather than the ASP.NET view engine, as that wonderful example above is Razor syntax.

Bob
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 37816172
Thank you!

Tom

I did pick "Razor" when creating the project.  I'll have to read more about "Razor" online.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question