Bannerman
Bannerman

Reputation: 101

Using Bootstrap Badges Within @Html.ActionLink

I'd like to create a basic bootstrap button with a badge using Razor @Html.ActionLink syntax. I tried the following:

@Html.ActionLink(@Html.Raw("<span class=\"badge\">42</span>")+"System Message Here", "Index", "Message", null, new { @class = "btn btn-default" })

Which results in this. I would like to see the badge icon instead of the HTML. What is the correct syntax? Thanks in advance.

Upvotes: 2

Views: 2535

Answers (1)

Kevin Ji
Kevin Ji

Reputation: 10499

You could just use Url.Action instead, like so:

<a href="@Url.Action("Index", "Message")" class="btn btn-default">
    <span class="badge">42</span> System Message Here
</a>

Upvotes: 3

Related Questions