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.

  1. Go to ElevenNote.WebMVC -> Views -> Shared -> _layout.cshtml

  2. Add the Notes route after Home:

         <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>
  3. 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>
  4. Git

  5. Run the app

  6. You should notice that the link to Notes is only there once you've logged in

    Notes Link

Last updated