Solved

Hide a tab in MVC

Posted on 2012-04-05
3
670 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:knowlton
3 Comments
 
LVL 22

Assisted Solution

by:ambience
ambience earned 450 total points
Comment Utility
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
Comment Utility
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:knowlton
Comment Utility
Thank you!

Tom

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now