2
我有一些麻煩讓Ajax.ActionLink工作如何我期望。ASP.NET MVC 3 Ajax.ActionLink
在/views/layout/_Layout.cshtml我加載以下腳本
<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/MicrosoftMvcAjax.js")" type="text/javascript"></script>
在/views/home/index.chstml我
@Ajax.ActionLink("Check Status", "GetStatus", new AjaxOptions { UpdateTargetId = "status", HttpMethod = "GET", InsertionMode = InsertionMode.Replace })
<div id="status">
Status
</div>
並在控制器/ HomeController我有
public string GetStatus()
{
return "Status ok " + DateTime.Now;
}
當我點擊按鈕時,它會將我帶到/ home/GetStatus並顯示狀態確定和當前日期和時間。
我預計它簡單地更新事業部區域
所以我在這裏找到了解決方案http://weblogs.asp.net/owscott/archive/2010/11/17/mvc-3-ajax-redirecting-instead-of-updating-div.aspx?CommentPosted=true #commentmessage對於有此問題的其他人,請檢查該頁面,因爲它提供了多個修補程序。 – Roge 2011-06-16 23:03:22