I am working on asp.net MVC 2 application. I have ajax.action link but it is not working. I have this code in my view:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<script type="text/javascript">
function success(result) {
alert(result);
// TODO: do something with the object
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%: Ajax.ActionLink(
"Delete",
"Delete",
new { Id = 55 },
new AjaxOptions { OnComplete = "success" })
%>
</asp:Content>
and this is controller code:
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
return View();
}
public JsonResult Delete(Int32 Id) {
return Json("Record deleted!", JsonRequestBehavior.AllowGet);
}
But when I click the link, It shows Record deleted! in browser instead of showing as alert. Am I missing some file(s) ?