问题是:我确实 Index.cshtml 为
@{
ViewBag.Title = "Search";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("../../Scripts/jquery.unobtrusive-ajax.min.js") type="text/javascript"></script>
<h2>Answer's are </h2>
<div id="result">
@Ajax.ActionLink("Search Wiki",
"WikiAns",
new AjaxOptions{
UpdateTargetId = "result",
InsertionMode=InsertionMode.Replace,
HttpMethod="GET",
LoadingElementId="progress"
})
</div>
<div id="progress" style="display: none">
<img src="@Url.Content("../../Content/Images/ajax-loader.gif")" alt="loader" />
</div>
现在我有部分视图模型 _WikiAns :
@model IEnumerable<Questions.Models.WikiAnsClass>
<h2>Our Links</h2>
<table>
@foreach (var item in Model) {
<tr>
<td>
<a href="@item.url" target="_blank">@item.content</a>
</td>
</tr>
}
</table>
现在使用我想要的是......点击搜索维基操作链接,id =“result”获取所有部分视图。但它没有发生。而不是进入页面“localhost:80/Search/WikiAns
”并在那里显示结果。但我希望它留在localhost:80/Search
并替换其“结果”ID。但它不是这样工作的。
以下是我的行为WikiAns
public ActionResult WikiAns()
{
//Code to follow...
var wikians = //code to follow
return PartialView("_wikiAns", wikians);
}
有什么问题?
另外我如何实现这个Ajax GIF加载器......我的意思是在执行动作时显示它。 ?
请建议
由于
答案 0 :(得分:0)
@Pbirkoff可能是对的,但你可以通过我的帖子非常容易地实现你的场景的演示并从那里构建它。
http://mazharkaunain.blogspot.com/2011/05/aspnet-mvc-razor-render-partial-view.html
http://mazharkaunain.blogspot.com/2011/04/aspnet-mvc-render-partial-view-using.html
答案 1 :(得分:0)
您需要在页面或布局中包含Microsoft Ajax脚本。