5.5: Navbar Addition
In this module we'll add a Notes Route to our navbar.
Adjusting the Nav Bar
Before we move on, let's make it easier to get to our notes by adding a tab in our Navbar.
Go to ElevenNote.WebMVC -> Views -> Shared -> _layout.cshtml
Add the
Notes
route afterHome
:<div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("Notes", "Index", "Note")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> @Html.Partial("_LoginPartial") </div>
We can refactor this to only show the
Notes
option if logged in:<div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li>@Html.ActionLink("Home", "Index", "Home")</li> @if (User.Identity.IsAuthenticated) { <li>@Html.ActionLink("Notes", "Index", "Note")</li> } <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul>
Run the app
You should notice that the link to
Notes
is only there once you've logged in
Last updated