我正在尝试将计数值从ASP.NET MVC ActionLink传递给PartialView。我第一次想要它加载9个故事。用户第二次单击该按钮时,会再加载6个故事,依此类推。我正在使用MVC Unobtrusive ajax异步加载故事,但不知道如何传递计数值。我只是将其设置为1。
查看
@model Models.HomePageModel
@{
AjaxOptions ajaxOpts = new AjaxOptions
{
UpdateTargetId = "tableBody"
};
}
<div id="tableBody">
@Html.Action("GetArticleData")
</div>
@using(Ajax.BeginForm("GetArticleData", ajaxOpts))
{
<div class="headlines-show-more">
<button type="submit">Show More News</button>
</div>
}
PartialViewResult的控制器
public PartialViewResult GetArticleData()
{
HomePageModel model = new HomePageModel();
model.GetDetails();
return PartialView(model);
}
PartialResult查看
@model Models.HomePageModel
@foreach (var item in Model.HeadlinesNews.Skip(0).Take(1))
{
<a>
<span>
<span>@item.Category</span>
<span></span>
<p>@item.NewsTitle</p>
</span>
</span></a>
}