I have the following navigation html/code now duplicated across several Views:
<ul class="topNav">
<li class="selected">@Html.ActionLink("Dashboard", "Dashboard", new { id = ViewContext.RouteData.GetRequiredString("id") })</li>
<li>@Html.ActionLink("Stats", "Stats", new { id = ViewContext.RouteData.GetRequiredString("id") })</li>
<li>@Html.ActionLink("Questions", "Questions", new { id = ViewContext.RouteData.GetRequiredString("id") })</li>
<li>@Html.ActionLink("Answers", "Answers", new { id = ViewContext.RouteData.GetRequiredString("id") })</li>
<li>@Html.ActionLink("Contacts", "Contacts", new { id = ViewContext.RouteData.GetRequiredString("id") })</li>
</ul>
Of course in each View the class="selected" of the li is changed. Is there an easy way to place this block of code in a Partial View or Layout View?
Also, must I really use ViewContext.RouteData.GetRequiredString("id") to get to the id parameter of the controller or is there a simpler way?