Solved

Hide a tab in MVC

Posted on 2012-04-05
3
683 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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