一旦用户添加项目,如何替换ajax.ActionLink添加ajax.ActionLink删除?

时间:2013-07-25 19:32:03

标签: jquery asp.net-mvc-4

我正在研究MVC 4项目,我想在用户将特定项目添加到项目列表后,使用删除操作链接动态替换添加操作链接?这有可能使用jQuery吗?

继承人的观点

@model mBooksAdmin.Models.Outlet`<tr class="even">
<td>
    @Model.OutletName
</td>
<td>
    @Model.Address1
</td>
<td>
    @Model.Address2
</td>
<td>
    @Model.City
</td>
<td>
    @Model.State
</td>
<td>
    @Model.Zip
</td>
<td>
    @Model.Country
</td>
<td>
    @Model.Banner
</td>
<td>
    @Ajax.ActionLink("Add", "Add", "Outlet", new { id = @Model.OutletID }, new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "searchResults", Confirm = "Are you sure you want to Add " + @Model.OutletName + " ?" }, null)
</td>

`

1 个答案:

答案 0 :(得分:0)

请参阅此文章,其中显示了如何使用MVC Ajax方法的默认OnSuccess()和OnFailure()方法:

<script type="text/javascript">
    function OnSuccess(ajaxContent) {
        // in chrome, click F12 and go to console to see what's inside...
        console.log(ajaxContent);
    }
</script>

参考。 ASP.NET MVC3 AJAX.BeginForm AjaxOptions OnSuccess OnFailure Problem