我正在尝试加载部分视图,它是使用MVC C#。
这是我的Controller(名为ArticlesController)
[HttpPost]
public PartialViewResult PaginatedArticles(int currentArticleCount, int currentPageN)
{
var model = new ArticlesViewModel();
IEnumerable<IPublishedContent> ArticleItems = CurrentPage.Children().Where(x => x.DocumentTypeAlias == "article");
var articles = _MapArticles.MapNewsItems(ArticleItems, Umbraco);
var totalArticles = articles.Count();
var totalPages = (int)Math.Ceiling((double)totalArticles / (double)pageSize);
model.CurrentPageN = currentPageN;
model.Articles = articles.Skip(currentArticleCount).Take(pageSize);
return PartialView("_ArticleBoxes", model);
}
我的视图我呼叫控制器。
@using (Ajax.BeginForm("PaginatedArticles", "Articles", null, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "articleBoxesWrapper"}, new { currentArticleCount = Model.PageSize * i, currentPageN = i }))
{
<input type="submit" value="@n">
}
还尝试了ajax.actionlink:
<li class="@isActive" >
@Ajax.ActionLink(n.ToString(), "PaginatedArticles","Articles",null, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "articleBoxesWrapper" }, new { currentArticleCount = Model.PageSize * i, currentPageN = i } )
</li>
我的问题:
它并没有全部击中控制器 相反,它会使用整个页面内容更新div。
我无法理解我做错了什么?