views:

22

answers:

2

I wish to return the following output

<a href="#"><img src="/images/icons/tick.png" alt="" />More info</a>

If i do the following the content is html encoded.

<%= Html.ActionLink("<img src='/images/icons/tick.png' />More info", "OrderRegion", "Campaign", new {id = Model.Campaign.Id}, null) %>

How can i disable the html encoding?

+3  A: 

I think you are better off using Url.Action here, e.g.:

<a href="<%= Url.Action("OrderRegion", "Campaign", new {id = Model.Campaign.Id}) %>">
    <img src="/images/icons/tick.png" alt="" />More info
</a> 
RedFilter
+1  A: 

you can create an HtmlHelper to this

public static class HtmlHelpers
{
    public static string MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
    {
        var tagActionLink = htmlHelper.ActionLink("[replace]", actionName, controllerName, routeValues, htmlAttributes).ToHtmlString();
        return tagActionLink.Replace("[replace]", linkText);
    }
}

in .aspx:

<%= Html.MyActionLink("<img src='/images/icons/tick.png' />More info", "OrderRegion", "Campaign", new {id = 15}, null) %>