2016-01-20 74 views
0

如何使用Bootstrap徽章類在按鈕旁顯示數字?在這種情況下,我使用@ActionLink。我在Bootstrap頁面上看到,我應該爲徽章使用HTML跨度。如何在MVC Razor中使用Bootstrap徽章類?

代碼:

 <div class="row"> 
      <div class="col-md-2"> 
       <div class="list-group"> 
        @Html.ActionLink("Home", "Index", "Home", null, new { @class = "list-group-item" }) 
        @Html.ActionLink("Auto's", "Lijst", "Auto", null, new { @class = "list-group-item" }) 
        @Html.ActionLink("Medewerkers", "Lijst", "Medewerker", null, new { @class = "list-group-item" }) 
<!--This one!--> @Html.ActionLink("Dagprogramma", "Dagprogramma", "Medewerker", null, new { @class = "list-group-item"}) 
        @Html.ActionLink("Contact", "Contact", "Home", null, new { @class = "list-group-item" }) 
       </div> 
      </div> 
+0

標誌不是徽標嗎? 5您只需將其放在該動作鏈接的左側即可。如果這不是你的意思,請澄清。 –

+0

沒有工作,無論如何。它只是把這個徽章放在ActionLink –

回答

3

不能包括由ActionLink helper方法生成的鏈接標記內自定義HTML標記。你可以做的是,寫一個錨標籤並在其中包含span。使用Url.Action方法可以爲動作方法生成正確的相對URL,您將使用該方法作爲鏈接的href屬性值。

@Html.ActionLink("Medewerkers", "Lijst", "Medewerker", null, 
                new { @class = "list-group-item" }) 

    <a href="@Url.Action("Dagprogramma","Medewerker")" 
       class="list-group-item"> Dagprogramma <span class="badge">99</span> 
    </a> 
    @Html.ActionLink("Contact", "Contact", "Home", null, 
                 new { @class = "list-group-item" }) 
+0

的上面,我只是試過這個,它確實有效,但不是它應該的樣子。它會創建一個額外的文本,並不會將該徽章放在ActionLink上。 屏幕截圖:http://prntscr.com/9sotj3 –

+0

你確定你的標記是正確的。我複製並從答案粘貼,並嘗試它,它對我來說很好,http://prntscr.com/9sovgj – Shyju

+0

哦,我的上帝......它工作哈哈,對不起 –