小编典典

Html.ActionLink 作为按钮或图像,而不是链接

all

在 ASP.NET MVC 的最新 (RC1) 版本中,如何让 Html.ActionLink 呈现为按钮或图像而不是链接?


阅读 68

收藏
2022-04-07

共1个答案

小编典典

延迟响应,但您可以保持简单并将 CSS 类应用于 htmlAttributes 对象。

<%= Html.ActionLink("Button Name", "Index", null, new { @class="classname" }) %>

然后在您的样式表中创建一个类

a.classname
{
    background: url(../Images/image.gif) no-repeat top left;
     display: block;
     width: 150px;
     height: 150px;
     text-indent: -9999px; /* hides the link text */
}
2022-04-07