Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.ActionLink as a button or an image, not a link

In the latest (RC1) release of ASP.NET MVC, how do I get Html.ActionLink to render as a button or an image instead of a link?

like image 630
Ryan Lundy Avatar asked Feb 27 '09 20:02

Ryan Lundy


1 Answers

I like to use Url.Action() and Url.Content() like this:

<a href='@Url.Action("MyAction", "MyController")'>     <img src='@Url.Content("~/Content/Images/MyLinkImage.png")' /> </a> 

Strictly speaking, the Url.Content is only needed for pathing is not really part of the answer to your question.

Thanks to @BrianLegg for pointing out that this should use the new Razor view syntax. Example has been updated accordingly.

like image 62
jslatts Avatar answered Sep 20 '22 04:09

jslatts