【问题标题】:Highlight the specific menu tab in mvc layout突出显示 mvc 布局中的特定菜单选项卡
【发布时间】:2014-05-06 01:31:19
【问题描述】:

我是 asp.net 或 mvc 开发的新手,我正在尝试将静态 html 模板转换为 asp.net mvc

我在菜单项的布局页面中有代码

  • class="active">@Html.ActionLink("Home","Index")
  • @Html.ActionLink("Destinations","Destinations")
  • @Html.ActionLink("Support","Support")
  • @Html.ActionLink("关于我们", "About_US")
  • @Html.ActionLink("Blog","Blog")
  • @Html.ActionLink("联系我们","Contact_US")

在静态网站中,我可以轻松地为特定页面粘贴 class="active" 以突出显示特定选项卡,因为我们必须为每个静态页面重复相同的代码,但我不知道如何在 MVC 中执行此操作我们对所有操作只有一种布局。

【问题讨论】:

    标签: asp.net-mvc


    【解决方案1】:

    见下文

    @Html.ActionLink("linkText",
        "Action",
        "Controller",
        new { /*routing values, leave empty if nothing specific*/ }, 
        new { @class = "active" /*all html attributes (id, style, rel, etc) goes here*/ })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 2020-07-06
      • 1970-01-01
      相关资源
      最近更新 更多