如何使用确认对话框为动作链接提供图像

时间:2014-01-08 19:11:20

标签: asp.net-mvc asp.net-mvc-4

下面的代码不起作用。

没有confirm它可以正常工作,但confirm无法正常工作。

<a href="@Url.Action ("action" , "controller" , new {idd=item.id } , new { onclick="return confirm ( ' are you sure ?');"})">
 <Img src=@Url.Content ("~/Content/icons/tag.icon")" />
</a>

1 个答案:

答案 0 :(得分:0)

Url.Action没有像某些Html助手那样的htmlAttributes参数等。只需将onclick =“...”直接添加到'a'标签。

<a href="@Url.Action("Test2", "Home", new { idd = 2 })" onclick="return confirm('are you sure?');">