Reputation: 6170
I'm using the following code to generate this:
<p>@Html.ActionLink("Read", "Index", "News", null, new { @class = "btn btn-default" })</p>
But I want to make a button that looks like this (with the use of HTML character »
):
However when I do the following:
<p>@Html.ActionLink("Read »", "Index", "News", null, new { @class = "btn btn-default" })</p>
I get this:
How do I fix this?
Upvotes: 7
Views: 3839
Reputation: 5135
Other solutions given here work. But just in case you are wondering, what to do if you dont have the special character on keyboard, here it goes:
You can either use
<a href='@Url.Action("Index", "News")' class="btn btn-default">Read »</a>
OR
@Html.ActionLink(HttpUtility.HtmlDecode("Read »"), "Index", "News", null, new { @class = "btn btn-default" })
Upvotes: 12
Reputation: 3342
<p>@Html.ActionLink("Learn More »", "Index", "News", null, new { @class = "btn btn-default" })</p>
As @MatteoSp said, just use the actual character in your string. The above ActionLink
will give you a button as you desired.
Upvotes: 0
Reputation: 3048
The text will be encoded by ActionLink() implementation, so you don't need to do it. Just use that char in the string.
Upvotes: 2