Reputation: 15
Have a nice day,I faced problem when i use Ajax.BeginForm,its like that when i enter jquery-1.8.2.min.js its display confirm message but when i click ok img it doesn't delete value but i remove jquery-1.8.2.min.js and click img it doesn't display confirm message but value delete correctly i can't find where is the error please help me Thanks!
This is my code ---
<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" />
}
Upvotes: 0
Views: 1001
Reputation: 154
if you want do delete something, first of all the HttpMethod should be "POST" since you want to delete an Employee by ID( to send data we use POST), second the ActionResult should be anotated as HttpPost.
[HttpPost]
public ActionResult Delete(int id)
{
//code here
return RedirectToAction();
}
This is the thing you should do in the first place, then fix the further bugs
Upvotes: 1