久久久久久久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 - 導航和突出顯示“當前";關聯

        ASP.net MVC - Navigation and highlighting the quot;currentquot; link(ASP.net MVC - 導航和突出顯示“當前;關聯)
        <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 - 導航和突出顯示“當前";關聯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  當您創建一個新的 MVC 項目時,它會創建一個帶有以下標記的 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>
                  

                  如果我在該頁面上,我想在此處放置代碼以突出顯示當前鏈接.

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

                  如果我添加另一個鏈接,例如:

                  If I add another link such as:

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

                  如果我在 Products 控制器中執行任何操作,我希望 Products 鏈接處于活動狀態(使用 .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 鏈接應該處于活動狀態.如果我在 HomeController 的 Index 操作中,Home 鏈接應該是活動的.

                  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 中執行此操作的最佳方法是什么?

                  What is the best way to do this in MVC?

                  推薦答案

                  查看這篇博文

                  它展示了如何創建一個您調用的 HTML 擴展,而不是通常的 Html.ActionLink 該擴展然后將 class="selected" 附加到列表項目前處于活動狀態.

                  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

                  編輯

                  只是添加一些代碼而不僅僅是一個鏈接.

                  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);
                  
                  
                      }
                  } 
                  

                  現在你需要在你的 CSS 中定義你的 selected 類,然后在你的視圖中在頂部添加一個 using 語句.

                  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")

                  這篇關于ASP.net MVC - 導航和突出顯示“當前";關聯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

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

                            主站蜘蛛池模板: 毛片av在线| www.国产在线 | 国产精品免费一区 | 久久视频免费观看 | 青青久久| 亚洲高清在线视频 | 成人一区二区三区 | 国产精品美女在线观看 | 国产主播一区二区 | 日韩在线小视频 | 91精品一区二区 | 在线中文字幕 | 羞羞网站入口 | 一级黄色免费看 | 成年在线观看 | 日韩久久一区 | 日韩一区在线播放 | 欧美色综合 | 精品视频免费观看 | 精品亚洲一区二区 | www国产亚洲精品久久网站 | 欧美激情视频一区二区三区 | 国产精品自拍第一页 | 一二三区视频 | 狠狠干在线视频 | 国产久 | 97中文字幕 | 欧美高清视频在线观看mv | 午夜美女福利 | 久操福利| 日日夜夜综合 | 婷婷激情综合 | 四虎8848| 网站av| 国产a级大片 | 日韩三级久久 | 亚洲激情另类 | 欧美日韩免费视频 | a级片在线| 成人动态视频 | 亚洲欧美在线视频 |