加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 具有确认对话框的MVC3 Actionlink

发布时间:2020-12-15 23:25:42 所属栏目:asp.Net 来源:网络整理
导读:可以显示ActionLink的确认消息吗? 我需要使用javascript吗?有没有可能吗? 你可以给我一些例子吗? 谢谢. //I want to make a confirmation message appear before the link opens.@Html.ActionLink("Checkout and view order list","Order","Order") 解决
可以显示ActionLink的确认消息吗?

我需要使用javascript吗?有没有可能吗?

你可以给我一些例子吗?

谢谢.

//I want to make a confirmation message appear before the link opens.
@Html.ActionLink("Checkout and view order list","Order","Order")

解决方法

使用重载Html.ActionLink(string linkText,string actionName,string controllerName,对象RouteValues,对象HtmlAttributes)和一些javascript,您可以执行以下操作:
@Html.ActionLink("Checkout and view order list",null,new { onclick="return confirm('Are you sure you want to click this link?')" })

这将添加HTML属性onclick,它将在点击链接时执行指定的javascript.如果链接上的onclick事件(或表单的提交按钮)返回false,则该操作(链接后,发布表单)不会发生.确认(消息)功能向用户显示带有指定消息的确认对话框,并根据用户的响应返回true或false.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读