I admire the layout and design of the TFS website, so I decided to challenge myself by recreating it using ASP.NET MVC.
My current focus is on replicating the 2-tiered horizontal navigation bar from the TFS website. Despite my efforts, I am struggling to implement this correctly and have resorted to using ViewBag to apply the active class on the selected action.
Below is the code snippet that I currently have:
<ul id="myTab" class="nav nav-tabs">
<li class="@(ViewBag.TopTabIndex == 0 ? "active" : "")"><a href="#home" data-toggle="tab">Home</a></li>
<li class="@(ViewBag.TopTabIndex == 1 ? "active" : "")"><a href="#reportingsuite" data-toggle="tab">Reporting Suite</a></li>
<li class="@(ViewBag.TopTabIndex == 2 ? "active" : "")"><a href="#pivotgrid" data-toggle="tab">Pivot Grid Analysis</a></li>
<li class="@(ViewBag.TopTabIndex == 3 ? "active" : "")"><a href="#reportserver" data-toggle="tab">Report Server Management</a></li>
<li class="@(ViewBag.TopTabIndex == 4 ? "active" : "")"><a href="#datawarehouse" data-toggle="tab">Data Warehouse</a></li>
</ul>
While this is functioning as intended, I now face the challenge of creating a sub-level navigation system aligned with my goals, but I'm currently stuck in achieving this.
Can someone provide guidance on how I should proceed to create a sub-level dependent navigation system while utilizing ViewBag to set it as active?
My initial thoughts are reflected in the following structure:
<div class="divide-nav">
<div class="container-fluid">
<ul id="myTab" class="nav nav-tabs">
<li class="@(ViewBag.TopTabIndex == 0 ? "active" : "")"><a href="#home" data-toggle="tab">Home</a></li>
<li class="@(ViewBag.TopTabIndex == 1 ? "active" : "")"><a href="#reportingsuite" data-toggle="tab">Reporting Suite</a></li>
<li class="@(ViewBag.TopTabIndex == 2 ? "active" : "")"><a href="#pivotgrid" data-toggle="tab">Pivot Grid Analysis</a></li>
<li class="@(ViewBag.TopTabIndex == 3 ? "active" : "")"><a href="#reportserver" data-toggle="tab">Report Server Management</a></li>
<li class="@(ViewBag.TopTabIndex == 4 ? "active" : "")"><a href="#datawarehouse" data-toggle="tab">Data Warehouse</a></li>
</ul>
</div>
</div>
<div class="sub-nav">
<div class="container-fluid">
<ul id="myTab" class="nav nav-tabs">
<li class="@(ViewBag.TopTabIndex == 0.1 ? "active" : "")"><a href="#home" data-toggle="tab">Overview</a></li>
<li class="@(ViewBag.TopTabIndex == 1.1 ? "active" : "")"><a href="#reportingsuite" data-toggle="tab">Overview</a></li>
<li class="@(ViewBag.TopTabIndex == 2.2 ? "active" : "")"><a href="#pivotgrid" data-toggle="tab">Overview</a></li>
<li class="@(ViewBag.TopTabIndex == 3.3 ? "active" : "")"><a href="#reportserver" data-toggle="tab">Overview</a></li>
<li class="@(ViewBag.TopTabIndex == 4.5 ? "active" : "")"><a href="#datawarehouse" data-toggle="tab">Overview</a></li>
</ul>
</div>
</div>
However, I require some logic to instruct the main navigation level to display the sub-level tabs based on the integer in the ViewBag.
Please refer to the image below for an example of my desired outcome.
Two Tiered Navigation Bar: