I am not sure where to start to implement tabs in a MVC project. Here is the problem. I want to implement tabs in a partial view but I want the tabs to be available to all my controllers and views. When I am coding the tabs I will need to know the current controller and view so I 开发者_开发技巧can modify the Html.ActionLink() with the tab QueryString.
How might I go about this
<%= Html.ActionLink(QuestionSort.SortArray[0], "Current View", "Current Controller", null, new { rel = "nofollow" })%>
<% for (int x = 1; x < QuestionSort.SortArray.Length; x++)
{ %>
<%= Html.ActionLink(QuestionSort.SortArray[x], "Current View", "Current Controller", new { sort = Server.UrlEncode(QuestionSort.SortArray[x]) }, new { rel = "nofollow" })%>
<% } %>
You can get the current controller from the ViewContext route values.
I would recommend that because you'll be putting some code into this in order to work that out, that you might want to write an HtmlHelper method to generate some of your HTML here - however:
<%= this.ViewContext.RouteData.Values["controller"] %>
Would print out the controller name
and
<%= this.ViewContext.RouteData.Values["action"] %
The action
It should be simple enough to build a context aware menu from this data
精彩评论