Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 想要在Html.ActionLink中使用带有文本的图像_Css_Asp.net Mvc_Model View Controller_Asp.net Mvc 3 - Fatal编程技术网

Css 想要在Html.ActionLink中使用带有文本的图像

Css 想要在Html.ActionLink中使用带有文本的图像,css,asp.net-mvc,model-view-controller,asp.net-mvc-3,Css,Asp.net Mvc,Model View Controller,Asp.net Mvc 3,我正在使用以下工具: <img src="../../Content/Images/lock_16.gif" /> @Html.ActionLink("Register", "Register", "Users", null, new { title = "Register your ID", rel = "nofollow" }) @ActionLink(“注册”, “注册”, “用户”, 无效的 新建{title=“注册您的ID”,rel=“

我正在使用以下工具:

<img src="../../Content/Images/lock_16.gif" />
@Html.ActionLink("Register", 
   "Register", 
   "Users", 
   null, 
   new { title = "Register your ID", rel = "nofollow" 
})

@ActionLink(“注册”,
“注册”,
“用户”,
无效的
新建{title=“注册您的ID”,rel=“nofollow”
})
我想要的是锁图像出现在
的内部,因此它是可点击的,而不是在它之前。我已经使用了背景图像(并在悬停时更改颜色),因此无法使用“背景图像”属性来显示图像


谁能想出一种方法,我可以设置图像,使其显示在文本之前,并且仍然可以单击。希望我能找到一种仍然允许我使用MVC Html.ActionLink的方法。

ASP.NET MVC中的Html帮助程序在简化代码编写时应该使用,但不总是这样。在您的情况下,纯html会更好

<a href="@Url.Action("Register", "Users")" title="Register Your ID", rel="nofollow">
     Register <img src="@Url.Content("~/Content/Images/lock_16.gif")" />
</a>


请注意,链接地址仍然是使用
UrlHelper.Action
方法动态生成的。这样,您就不会丢失对路由配置的链接依赖性。另外,正如Nicholas提到的,图像源应该通过
Url.Content
helper生成。

您可以使用-

@Html.ActionLink("link Name", "Action Method", "Controller", new { style = "background-image:url('.././Images/imageName.png')" },null)

你可能想重新表述你的问题。“出现在里面”是什么意思?你的意思是你想让图像和文本都可以点击吗?对不起,我不清楚。是的,我希望图像和文本显示在中,并且两者都可以单击。您还应该使用的副本我认为ur ans比Mark的ans更好,尽管此代码可能有助于解决问题,提供有关为什么和/或如何回答问题的附加上下文将显著提高其长期价值。请在您的回答中添加一些解释。
@Html.ActionLink("link Name", "Action Method", "Controller", 
   new { style = "background-image:url('.././Images/imageName.png')" },
   null)