I recently completed my first web application using ASP.NET.
https://i.sstatic.net/8HRQj.png
Now, I have the top navigation (red arrow) displayed on all pages of my web app. How can I hide it from specific pages so that users only see the side navigation (purple arrow)?
Do I need to make changes in the controller or in my _Layout.cshtml file?
Below is the code snippet for this page:
@{
/**/
ViewBag.Title = "AfterLogin";
}
<link href="~/Content/SidebarMenu.css" rel="stylesheet" />
<link href="~/Content/TOdo.css" rel="stylesheet" />
<script src="~/Scripts/todo.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<h2>To Do App</h2>
@if (Session["UserID"] != null)
{
<div>
Welcome : <a href="#"> @Session["UserName"] </a><br />
<a href="/Register/Logout"> Logout</a>
</div>
<html>
<head>
</head>
<body>
<div class="area"></div><nav class="main-menu">
<ul>
<li>
<a href="http://justinfarrow.com">
<i class="fa fa-home fa-2x"></i>
<span class="nav-text">
Dashboard
</span>
</a>
</li>
<!-- More list items here -->
</ul>
<ul class="logout">
<li>
<a href="/Register/Logout">
<i class="fa fa-power-off fa-2x"></i>
<span class="nav-text">
Logout
</span>
</a>
</li>
</ul>
</nav>
<body>
<!-- Your additional content here -->
</body>
</html>
}
AND here is the _Layout.cshtml code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>