Strings returned in your templates by means of the @
razor syntax are by default HTML encoded in order to not output HTML markup directly.
var s = "<p>text</p>";
....
@s
will output something similar to
<p>text</p>
In order to prevent this, you could use HtmlHelper
s Raw
method:
@Html.Raw(s)
Or you may use a HtmlString
(or before .NET 4, MvcHtmlString
):
var s = new HtmlString("<p>text</p>");
By using a HtmlString
(MvcHtmlString
), razor knows not to HTML-encode the output string.
In your particular case you therefore either use @Html.Raw(Html.LinkButton(...))
, or you change the output type of your helper extension:
public static HtmlString LinkButton(this HtmlHelper helper, string id, string value, string target, object htmlAttributes)
...
return new HtmlString(linkButton.ToString());