久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='wlQBF'><style id='wlQBF'><dir id='wlQBF'><q id='wlQBF'></q></dir></style></legend>

        <small id='wlQBF'></small><noframes id='wlQBF'>

          <bdo id='wlQBF'></bdo><ul id='wlQBF'></ul>

        <i id='wlQBF'><tr id='wlQBF'><dt id='wlQBF'><q id='wlQBF'><span id='wlQBF'><b id='wlQBF'><form id='wlQBF'><ins id='wlQBF'></ins><ul id='wlQBF'></ul><sub id='wlQBF'></sub></form><legend id='wlQBF'></legend><bdo id='wlQBF'><pre id='wlQBF'><center id='wlQBF'></center></pre></bdo></b><th id='wlQBF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wlQBF'><tfoot id='wlQBF'></tfoot><dl id='wlQBF'><fieldset id='wlQBF'></fieldset></dl></div>
        <tfoot id='wlQBF'></tfoot>
      1. ASP.net MVC - 導(dǎo)航和突出顯示“當(dāng)前";關(guān)聯(lián)

        ASP.net MVC - Navigation and highlighting the quot;currentquot; link(ASP.net MVC - 導(dǎo)航和突出顯示“當(dāng)前;關(guān)聯(lián))
        <i id='BZH59'><tr id='BZH59'><dt id='BZH59'><q id='BZH59'><span id='BZH59'><b id='BZH59'><form id='BZH59'><ins id='BZH59'></ins><ul id='BZH59'></ul><sub id='BZH59'></sub></form><legend id='BZH59'></legend><bdo id='BZH59'><pre id='BZH59'><center id='BZH59'></center></pre></bdo></b><th id='BZH59'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BZH59'><tfoot id='BZH59'></tfoot><dl id='BZH59'><fieldset id='BZH59'></fieldset></dl></div>

      2. <small id='BZH59'></small><noframes id='BZH59'>

              <bdo id='BZH59'></bdo><ul id='BZH59'></ul>
              <legend id='BZH59'><style id='BZH59'><dir id='BZH59'><q id='BZH59'></q></dir></style></legend>

                <tfoot id='BZH59'></tfoot>
                  <tbody id='BZH59'></tbody>

                1. 本文介紹了ASP.net MVC - 導(dǎo)航和突出顯示“當(dāng)前";關(guān)聯(lián)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  當(dāng)您創(chuàng)建一個(gè)新的 MVC 項(xiàng)目時(shí),它會(huì)創(chuàng)建一個(gè)帶有以下標(biāo)記的 Site.master:

                  When you create a new MVC project it creates a Site.master with the following markup:

                  <div id="menucontainer">
                      <ul id="menu">
                          <li><%: Html.ActionLink("Home", "Index", "Home")%></li>
                          <li><%: Html.ActionLink("About", "About", "Home")%></li>
                      </ul>
                  </div>
                  

                  如果我在該頁(yè)面上,我想在此處放置代碼以突出顯示當(dāng)前鏈接.

                  I would like to put code in here that will highlight the current link if I am on that page.

                  如果我添加另一個(gè)鏈接,例如:

                  If I add another link such as:

                  <li><%: Html.ActionLink("Products", "Index", "Products")%></li>
                  

                  如果我在 Products 控制器中執(zhí)行任何操作,我希望 Products 鏈接處于活動(dòng)狀態(tài)(使用 .active 之類的 css 類).

                  I would want the Products link to be active (using a css class like .active) if I'm on any action in the Products controller.

                  如果我在 HomeController About 操作中,About 鏈接應(yīng)該處于活動(dòng)狀態(tài).如果我在 HomeController 的 Index 操作中,Home 鏈接應(yīng)該是活動(dòng)的.

                  The About link should be active if I'm on the HomeController About action. The Home link should be active if I'm on the Index action of the HomeController.

                  在 MVC 中執(zhí)行此操作的最佳方法是什么?

                  What is the best way to do this in MVC?

                  推薦答案

                  查看這篇博文

                  它展示了如何創(chuàng)建一個(gè)您調(diào)用的 HTML 擴(kuò)展,而不是通常的 Html.ActionLink 該擴(kuò)展然后將 class="selected" 附加到列表項(xiàng)目前處于活動(dòng)狀態(tài).

                  It shows how to create an HTML Extension that you call instead of the usual Html.ActionLink The extension then appends class="selected" to the list item that is currently active.

                  然后,您可以在 CSS 中添加任何您想要的格式/突出顯示

                  You can then put whatever formatting/highlighting you want in your CSS

                  編輯

                  只是添加一些代碼而不僅僅是一個(gè)鏈接.

                  Just adding some code to rather than just a link.

                  public static class HtmlHelpers
                  {
                  
                      public static MvcHtmlString MenuLink(this HtmlHelper htmlHelper,
                                                          string linkText,
                                                          string actionName,
                                                          string controllerName
                                                          )
                      {
                  
                          string currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action");
                          string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
                  
                          if (actionName == currentAction && controllerName == currentController)
                          {
                              return htmlHelper.ActionLink(linkText, actionName, controllerName, null, new { @class = "selected" });
                          }
                  
                          return htmlHelper.ActionLink(linkText, actionName, controllerName);
                  
                  
                      }
                  } 
                  

                  現(xiàn)在你需要在你的 CSS 中定義你的 selected 類,然后在你的視圖中在頂部添加一個(gè) using 語(yǔ)句.

                  Now you need to define your selected class in your CSS and then in your views add a using statement at the top.

                  @using ProjectNamespace.HtmlHelpers

                  并使用 MenuLink 代替 ActionLink

                  @Html.MenuLink("Your Menu Item", "Action", "Controller")

                  這篇關(guān)于ASP.net MVC - 導(dǎo)航和突出顯示“當(dāng)前";關(guān)聯(lián)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時(shí)忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯(cuò)誤的 XML)

                    <tbody id='PIWom'></tbody>
                  • <legend id='PIWom'><style id='PIWom'><dir id='PIWom'><q id='PIWom'></q></dir></style></legend>

                    <small id='PIWom'></small><noframes id='PIWom'>

                    <tfoot id='PIWom'></tfoot>
                    <i id='PIWom'><tr id='PIWom'><dt id='PIWom'><q id='PIWom'><span id='PIWom'><b id='PIWom'><form id='PIWom'><ins id='PIWom'></ins><ul id='PIWom'></ul><sub id='PIWom'></sub></form><legend id='PIWom'></legend><bdo id='PIWom'><pre id='PIWom'><center id='PIWom'></center></pre></bdo></b><th id='PIWom'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PIWom'><tfoot id='PIWom'></tfoot><dl id='PIWom'><fieldset id='PIWom'></fieldset></dl></div>
                        • <bdo id='PIWom'></bdo><ul id='PIWom'></ul>

                            主站蜘蛛池模板: 中文字幕在线观看一区 | 亚洲欧美视频一区 | 天天人人精品 | 午夜小视频在线观看 | 黄色片a级 | 精品少妇一区二区三区日产乱码 | 一区在线观看 | 国产一区二区三区免费 | 麻豆精品一区二区三区在线观看 | 国产免费一区二区三区 | 99久久精品免费看国产四区 | 久久国产精品-国产精品 | www久久国产 | 国产精品永久久久久久久www | 精品久久久久久久久久久久 | 国产综合视频 | 五月天天丁香婷婷在线中 | 中文字幕一区二区三区在线观看 | 手机在线观看av | 免费日韩av网站 | av中文天堂 | 成人影院在线视频 | 日韩中文字幕视频在线观看 | 日韩视频中文字幕 | 超碰国产在线 | 中文字幕一区二区视频 | 性高湖久久久久久久久 | 亚洲成人一区二区 | 国产日韩视频 | 国产精品亚洲欧美日韩一区在线 | 丝袜美腿一区 | 久久久成人网 | 成人精品一区二区 | 久久精品二区 | 久久精品国产免费一区二区三区 | 亚洲精品日韩视频 | 在线观看中文字幕 | www.一区二区三区.com | 国产精品毛片av一区 | 日本在线中文 | 日本欧美国产在线 |