How to implement tabs in partial view in ASP MVC

I do not know where to start implementing tabs in an MVC project. Here is the problem. I want to implement tabs in a partial view, but I want the tabs to be accessible to all my controllers and views. When I encode tabs, I will need to find out the current controller and view, so I can change the Html.ActionLink () with the QueryString tab.

How can i do this

<%= Html.ActionLink(QuestionSort.SortArray[0], "Current View", "Current Controller", null, new { rel = "nofollow" })%>&nbsp;&nbsp;
<% 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" })%>&nbsp;&nbsp;    
<% } %>
+3
source share
1 answer

You can get the current controller from the ViewContext route values.

, - , , HtmlHelper HTML- - :

<%= this.ViewContext.RouteData.Values["controller"] %>

<%= this.ViewContext.RouteData.Values["action"] %

, -

+2

Source: https://habr.com/ru/post/1731994/


All Articles