Bry*_*oth 12 asp.net-mvc asp.net-ajax
如何将参数传递给ASP.NET MVC OnSuccess中的AjaxOptions类的函数?
这是我的代码,但它不起作用:
<%= Ajax.ActionLink("Delete",
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "updateCount('parameter')"
})
%>
Run Code Online (Sandbox Code Playgroud)
UPDATE
设置OnSuccess属性以(function(){updateCount('parameter');})解决我的问题:
<%= Ajax.ActionLink("Delete",
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "(function(){updateCount('parameter');})"
})
%>
Run Code Online (Sandbox Code Playgroud)
Dav*_*sky 10
您应该能够使用jQuery选择器从页面中的字段填充值:
<%= Ajax.ActionLink("Delete",
"Delete",
"MyController",
New With {.id = record.ID},
New AjaxOptions With
{
.Confirm = "Delete record?",
.HttpMethod = "Delete",
.OnSuccess = "updateCount($('#SomeField).val()))"
})
%>
Run Code Online (Sandbox Code Playgroud)
另请看一下:我可以在Ajax.ActionLink中使用OnSuccess事件传递参数
| 归档时间: |
|
| 查看次数: |
12203 次 |
| 最近记录: |