使周围的ASP.NET MVC图像的Html.ActionLink? [英] Make an Html.ActionLink around an Image in ASP.NET MVC?

查看:141
本文介绍了使周围的ASP.NET MVC图像的Html.ActionLink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可怎么办类似Html.ActionLink()的东西,除了地方生成的链接图像周围的,而不是仅仅吐出的联系?

How can I do something similar to Html.ActionLink() except place the generated link around an Image instead of just spitting out the link?

推荐答案

剃须刀(视图引擎):

<a href="@Url.Action("ActionName", "ControllerName")">
    <img src="@Url.Content("~/Content/img/imgname.jpg")" />
</a>

ASPX(视图引擎):

ASPX (View Engine):

<a href="<%= Url.Action("ActionName", "ControllerName") %>">
    <img src="<%= Url.Content("~/Content/img/imgname.jpg") %>" />
</a>

显然,如果你做的比这一次更,写它的帮手。并填写IMG / a的其他属性。但是,这应该给你的总体思路。

Obviously, if you do this more than once, write a helper for it. And fill in the other attributes of img/a. But this should give you the general idea.

这篇关于使周围的ASP.NET MVC图像的Html.ActionLink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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