Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert a HTML character into this Html.ActionLink?

I'm using the following code to generate this:

<p>@Html.ActionLink("Read", "Index", "News", null, new { @class = "btn btn-default" })</p>

enter image description here

But I want to make a button that looks like this (with the use of HTML character &raquo;): enter image description here

However when I do the following:

<p>@Html.ActionLink("Read &raquo;", "Index", "News", null, new { @class = "btn btn-default" })</p>

I get this:

enter image description here

How do I fix this?

like image 596
user9993 Avatar asked Jun 02 '15 22:06

user9993


2 Answers

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 &raquo;</a>

OR

@Html.ActionLink(HttpUtility.HtmlDecode("Read &raquo;"), "Index", "News", null, new { @class = "btn btn-default" })
like image 146
Polynomial Proton Avatar answered Sep 20 '22 18:09

Polynomial Proton


The text will be encoded by ActionLink() implementation, so you don't need to do it. Just use that char in the string.

like image 28
MatteoSp Avatar answered Sep 19 '22 18:09

MatteoSp