0

祝你有美好的一天,我在使用 Ajax.BeginForm 时遇到了问题,就像我输入 jquery-1.8.2.min.js 时它显示确认消息但是当我单击 ok img 它不会删除值但我删除 jquery -1.8.2.min.js 并单击 img 它不显示确认消息但值删除正确我找不到错误在哪里请帮助我谢谢!

这是我的代码---

<script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript">/script>

<script src="../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript" ></script>

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>



@using (Ajax.BeginForm("Delete", "Employee", new { id = item.EmployeeId },new AjaxOptions
                   {//GetPacients is name of method in EmployeeController

                                 Confirm="Are you sure you want to delete this employee?",
                                 HttpMethod = "Get",
                                 InsertionMode = InsertionMode.Replace, 
                                 UpdateTargetId = "EnployeeViewTbale",

                  }))
        {

            <input type="image" class="deleteImage" src  ="Content/Images/delete3.png" />


        }
4

1 回答 1

1

如果你想删除一些东西,首先HttpMethod应该是“POST”,因为你想通过ID删除一个Employee(发送我们使用POST的数据),其次ActionResult应该被注释为HttpPost。

[HttpPost]
public ActionResult Delete(int id)
{
  //code here
 return RedirectToAction();
}

这是您首先应该做的事情,然后修复更多错误

于 2013-10-31T17:04:58.970 回答