Action Image MVC3 Razor
问题 What is the best way to replace links with images using Razor in MVC3. I simply doing this at the moment: <a href="@Url.Action("Edit", new { id=MyId })"><img src="../../Content/Images/Image.bmp", alt="Edit" /></a> Is there a better way? 回答1: You can create an extension method for HtmlHelper to simplify the code in your CSHTML file. You could replace your tags with a method like this: // Sample usage in CSHTML @Html.ActionImage("Edit", new { id = MyId }, "~/Content/Images/Image.bmp", "Edit")