Html.ActionLink 作为按钮或图像,而不是链接 [英] Html.ActionLink as a button or an image, not a link

查看:33
本文介绍了Html.ActionLink 作为按钮或图像,而不是链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

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

Late response but you could just keep it simple and apply a CSS class to the htmlAttributes object.

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

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

and then create a class in your stylesheet

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

这篇关于Html.ActionLink 作为按钮或图像,而不是链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆