ASP.NET MVC 3 Ajax.ActionLink
Im having some trouble getting Ajax.ActionLink to work how I expect.
In /views/layout/_Layout.cshtml I load the following scripts
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Micro开发者_开发技巧softMvcAjax.js")" type="text/javascript"></script>
In /views/home/index.chstml I have
@Ajax.ActionLink("Check Status", "GetStatus", new AjaxOptions { UpdateTargetId = "status", HttpMethod = "GET", InsertionMode = InsertionMode.Replace })
<div id="status">
Status
</div>
And in controllers/HomeController I have
public string GetStatus()
{
return "Status ok " + DateTime.Now;
}
When I click the button it takes me to /home/GetStatus And displays Status Ok and the current date and time.
I expected it to simply update the Div area
So I found the solution here Weblogs.asp.net For anyone else with this problem check the page as it offers multiple fixs. I basiclly left out reference to a javascript lib.
精彩评论