I have used PartialView but it renders the whole view after success full ajax post
This is my view
my ul which i want to update
<ul id="ULdinnerlist">
@* my foreach loop*@
@foreach (var item in Model)
{
<li> Title : @Html.DisplayFor(modelItem => item.Title)<br />
EventDate : @Html.Encode(item.EventDate.ToShortDateString()+ " @ " + item.EventDate.ToShortTimeString())
<p>Description : @Html.DisplayFor(modelItem => item.Description)</p><br />
HostedBy : <b>@Html.DisplayFor(modelItem => item.HostedBy)</b> (@item.ContactPhone)<br />
</li>
}
</ul>
我的 ajax 路由链接 @Ajax.RouteLink(">>>",new { page = Model.PageIndex + 1 },new AjaxOptions { UpdateTargetId = "ULdinnerlist" })
ON controller: my action for reindering
public ActionResult Index(int? Page)
{
int PageSize = 5;
IQueryable<Dinner> dines = from dine in db.Dinners orderby dine.EventDate select dine;
var paginatedDinners = new PagingList<Dinner>(dines, Page ?? 0, PageSize);
checking ajax post and rendering accordingly
if (Request.IsAjaxRequest())
{
return PartialView(paginatedDinners);
}
return View(paginatedDinners);
}
问题是当我进行分页时它会呈现整个视图。谢谢