who*_*ee1 13 confirmation asp.net-mvc-3
我可以显示确认消息ActionLink吗?
我需要使用javascript吗?没有它可能吗?
你能给我一些例子吗?
谢谢.
//I want to make a confirmation message appear before the link opens.
@Html.ActionLink("Checkout and view order list", "Order", "Order")
Run Code Online (Sandbox Code Playgroud)
yoo*_*er8 38
使用重载Html.ActionLink(string linkText, string actionName, string controllerName, object RouteValues, object HtmlAttributes)和一些JavaScript,您可以执行以下操作:
@Html.ActionLink("Checkout and view order list", "Order", "Order", null, new { onclick="return confirm('Are you sure you want to click this link?')" })
Run Code Online (Sandbox Code Playgroud)
这将添加HTML属性onclick,它将在单击链接时执行指定的javascript.如果链接上的onclick事件(或表单的提交按钮)返回false,则不会发生操作(在链接之后发布表单).该confirm(message)函数向用户显示包含指定消息的确认对话框,并根据用户的响应返回true或false.
| 归档时间: |
|
| 查看次数: |
25963 次 |
| 最近记录: |