MVC3 ActionLink的与确认对话框 [英] MVC3 Actionlink with confirmation dialog
问题描述
我可以显示一个确认信息 ActionLink的
?
我需要使用JavaScript?是否有可能没有它?
您能给我一些例子吗?
感谢您。
//我想打一个确认消息出现的链接打开之前。
@ Html.ActionLink(结帐并查看订单列表,订单,订单)
使用过载 Html.ActionLink(字符串LINKTEXT,串actionName,串controllerName,对象RouteValues,对象HtmlAttributes)
和一些JavaScript,你可以做到以下几点:
@ Html.ActionLink(结帐并查看订单列表,订单,订单,空,新{=的onclick返回确认(你确定要点击这个链接?')})
这将添加HTML属性的onclick,点击该链接时将执行指定的JavaScript。如果链接上的onclick事件(或表单的提交按钮)返回false,动作(下面的链接,发布形式)不会发生。在确认(消息)
函数显示用户使用指定的消息确认对话框,并根据用户的响应返回true或false。
Can I show a confirmation message for an ActionLink
?
Do I need to use javascript? Is it possible without it?
Could you give some example for me?
Thank you.
//I want to make a confirmation message appear before the link opens.
@Html.ActionLink("Checkout and view order list", "Order", "Order")
Using the overload Html.ActionLink(string linkText, string actionName, string controllerName, object RouteValues, object HtmlAttributes)
and some javascript, you can do the following:
@Html.ActionLink("Checkout and view order list", "Order", "Order", null, new { onclick="return confirm('Are you sure you want to click this link?')" })
This will add the HTML attribute onclick, which will execute the specified javascript when the link is clicked. If an onclick event on a link (or a form's submit button) returns false, the action (following the link, posting the form) doesn't happen. The confirm(message)
function shows the user a confirmation dialog with the specified message, and returns either true or false depending on the user's response.
这篇关于MVC3 ActionLink的与确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!