C#_Ajax分页MVCPager

UCJqOrderList

C#_Ajax分页MVCPager
    @model PagedList<Order>
<div id="dvOrders">
<table width="98%">
<tr><th>订单编号</th><th>订单日期</th><th>顾客编号</th><th>收货地址</th></tr>
@foreach(Order od in Model)
 {     
     <tr><td>@od.OrderID</td><td>@od.OrderDate.ToString()</td><td>@od.CustomerID</td>
     <td>@od.ShipAddress</td></tr>   
 } 
</table>
<p>Ajax分页(仅刷新部分页面,Url不改变):</p>
@Html.AjaxPager(Model, new PagerOptions() { PageIndexParameterName = "id", ShowDisabledPagerItems = false, AlwaysShowFirstLastPageNumber = true }, new AjaxOptions { UpdateTargetId = "dvOrders"})
<p>标准url分页(刷新整个页面,Url改变):</p>
@Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ShowDisabledPagerItems = false, AlwaysShowFirstLastPageNumber = true })
</div>
C#_Ajax分页MVCPager

 

JqAjaxOrders

C#_Ajax分页MVCPager
@{ ViewBag.Title = "MvcPager 使用 jQuery 分页示例";}
    @model PagedList<Order>

<script type="text/javascript" src="/Scripts/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<h2>ASP.NET MvcPager 使用 jQuery 分页示例</h2>
    <div>本示例演示使用MvcPager配合<a href="http://www.jquery.com" target="_blank">jQuery</a>实现Ajax分页。</div><br />   
@{Html.RenderPartial("UCJqOrderList", Model); }
C#_Ajax分页MVCPager

 

1
2
3
4
5
6
7
8
9
10
public ActionResult JqAjaxOrders(int id = 1)
   {
       using (var db = new OrderEntities())
       {
           PagedList<Order> orders = db.Orders.OrderBy(o => o.OrderID).ToPagedList(id, 20);
           if (Request.IsAjaxRequest())
               return PartialView("UCJqOrderList", orders);
           return View(orders);
       }
   }

 

C#_Ajax分页MVCPager,布布扣,bubuko.com

C#_Ajax分页MVCPager

上一篇:总结web应用中常用的各种cache(转)


下一篇:php字符串啊的heredoc格式