码迷,mamicode.com
首页 > Web开发 > 详细

C#_Ajax分页MVCPager

时间:2014-05-26 20:07:21      阅读:397      评论:0      收藏:0      [点我收藏+]

标签:cPage   style   c   class   blog   code   

UCJqOrderList

bubuko.com,布布扣
    @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>
bubuko.com,布布扣

 

JqAjaxOrders

bubuko.com,布布扣
@{ 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); }
bubuko.com,布布扣

 

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

标签:cPage   style   c   class   blog   code   

原文地址:http://www.cnblogs.com/MarchThree/p/3751862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!