Closed dwelford closed 10 years ago
I'm not sure I follow. What should @Html.Navigation()
do? Show me an example of desired html output. Also, which dropdown list are you referring to? I don't see any on the example provided.
Oh that loads all the configurations from the RouteConfig.cs In there I put all the routes for the menu navigation:
'routes.MapNavigationRoute<MaintenanceController>("Administration", c => c.Index())
.AddChildRoute<CompetitorController>("Compeditor File", c => c.Index())
.AddChildRoute<AddressesController>("Addresses", c => c.Index())
.AddChildRoute<TermCodesController>("Credit Terms", c => c.Index())
.AddChildRoute<CustomersController>("Customers", c => c.Index())
.AddChildRoute<InventoryController>("Inventory", c => c.Index())
.AddChildRoute<DriversController>("Drivers", c => c.Index())
.AddChildRoute<TypeSteelController>("Steel Type", c => c.Index())
.AddChildRoute<SalesPersonsController>("Sales Reps", c => c.Index())
Then by calling @Html.Navigation() this will load the routes for me into each dropdown:
I figure it out by reading the BootStrap 3 something i should have done first. _Layout file
<body>
<nav class="navbar navbar-fixed-top navbar-static-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand Name</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
@Html.Navigation()
@if (User.Identity.IsAuthenticated)
{
<li>@Html.ActionLink("Change Password", "ChangePassword", "SGAccount")</li>
}
@if (User.IsInRole("SecurityGuard"))
{
<li class="divider-vertical"></li>
<li>@Html.ActionLink("Security Guard", "Index", "Dashboard", new { area = "SecurityGuard" }, null)</li>
}
</ul>
<ul class="nav navbar-nav navbar-right">
@Html.Partial("_LoginPartial")
</ul>
<p class="navbar-text">@DateTime.Now.ToLongDateString()</p>
</div><!-- /.navbar-collapse -->
</nav>
<div class="container-fluid">
<div class="row-fluid">
@RenderBody()
</div>
<hr>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>
Application © @DateTime.Now.Year - Your company</p>
</div>
</div>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
Added the new stuff for BootStrap 3 this works just wondering if maybe there is a better way using your library.
Thanks
In the BMVC there is a disposable helper for creating nav
(maybe you'll find use for that), but not navbar
. The reason I didn't do anything with Navbar is that there are so many items inside it and you can put all them in different order... it allows for a lot of customization and I thought it does not make sense to try to automate it with helpers.
However, if you see a way to have some BMVC syntax that will ease up your life, I'm always listening.
I am using the below and want to convert to BootStrap()
<!DOCTYPE html>
@Html.Navigation() @if (User.Identity.IsAuthenticated) {- @Html.ActionLink("Change Password", "ChangePassword", "SGAccount")
}
@if (User.IsInRole("SecurityGuard"))
{
- @Html.ActionLink("Security Guard", "Index", "Dashboard", new { area = "SecurityGuard" }, null)
}
I am a little stuck on how to implement @Html.Navigation() to load the routes defined to the dropdown lists. Also is there a way to assign keys to dropdown items?
Just a question
Thanks