Improving Navigation
Now, we want to improve the navigation of our website. We want to add a back button from our detail view to index view.
Our designer team has already delivered the code needed.
<div class="backbar">
<div class="container">
<a class="btn btn-default" href="/">Return to List</a>
</div>
</div>
Put above code before rendering the body.
Then, we need the code showed up only in Detail page, not in Index page. Therefore, we need a variable called ShowBackBar that being assigned only in Detail page.
@if (ViewBag.ShowBackBar != null && ViewBag.ShowBackBar)
{
<div class="backbar">
<div class="container">
<a class="btn btn-default" href="/">Return to List</a>
</div>
</div>
}
Then, we have to declare the action performed when the button being pressed.
@if (ViewBag.ShowBackBar != null && ViewBag.ShowBackBar)
{
<div class="backbar">
<div class="container">
@Html.ActionLink("Return to List", "Index", null, new { @class = "btn btn-default" });
</div>
</div>
}