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

查看:1533
本文介绍了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天全站免登陆