[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Hide a tab in MVC

Posted on 2012-04-05
3
Medium Priority
?
696 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 1800 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 200 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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