ASP.NET MVC PartialViewResult


PartialViewResult返回的也是一个页面,可以使用@Html.Partial加载这个部分页面,需要多次使用的时候可以用到他

 public PartialViewResult _pxcx(string polName, string podName, string carrCode, string lineName, int page = 1)
        {
            int total = 0;
            var list = _Price_InfoManagement.GetDTO_PRICELCL_List(polName, podName, carrCode, "", "", lineName, "", page, pageSize, out total);
            ViewBag.Pager = PagerHelper.CreatePagerByAjax(page, pageSize, total, "lcl.priceQuery", false, lang == "CN");
            return PartialView(list);//传入集合aps.net会解析好,然后返回一个页面html
        }

@model List<GTDesk.Domain.MainModule.Entities.DTO.DTO_C_PRICE>  
 <table width="100%" border="0" class="lcl-table tac">
     <tr id="thead">
         <th scope="col">@ViewData["起始港"]</th>
         <th scope="col">@ViewData["目的港"]</th>
         <th scope="col">@ViewData["船公司"]</th>
         <th scope="col">@ViewData["船期"]</th>
         <th scope="col">@ViewData["航程"]</th>
         <th scope="col">@ViewData["中转港"]</th>
         <th scope="col">20GP</th>
         <th scope="col">40GP</th>
         <th scope="col">40HQ</th>
         <th scope="col">@ViewData["附加费"]</th>
         <th scope="col">@ViewData["有效日期"]</th>
         <th scope="col">@ViewData["Key_BookOnline"]</th>
     </tr>
     
   @if (Model != null && Model.Any())
   {
       foreach (var item in Model)
       {
           <tr>
    
               <td>@item.POL_NAME_EN</td>
               <td>@item.POD_NAME_EN</td>
               <td>@item.CARR_CODE</td>
               <td>@item.ETD </td>
               <td>@item.TRANSIT_TIME</td>
               <td>@(string.IsNullOrEmpty(item.POT_NAME_EN) ? "直达" : item.POT_NAME_EN)</td>
               <td> <p class="wz2">@(item.PR_PRICE_20.HasValue?item.PR_PRICE_20.Value.ToString("00"):"")</p></td>
               <td><p class="wz2">@(item.PR_PRICE_40.HasValue?item.PR_PRICE_40.Value.ToString("00"):"")</p></td>
               <td><p class="wz2">@(item.PR_PRICE_40HQ.HasValue?item.PR_PRICE_40HQ.Value.ToString("00"):"")</p></td>

加载部分页面

@Html.Partial("_pxcx", Model)

分页的时候其实就是改变的中间这一块,可以用ajax请求_pxcx,返回的是html在用js这返回的html加载到需要的地方就可以了

//拼箱
var lcl = {
    //运价查询
    priceQuery: function (index) {
        var polName = $("#POL_NAME_EN").combogrid('getValue');
        var lineName = $("#LineId").combobox('getValue');
        var podName = $('#POD_NAME_EN').combogrid('getValue');
        var carrCode = $('#CARR_CODE').combogrid('getValue');
        $.post('/home/_pxcx', { polName: polName, podName: podName, carrCode: carrCode, lineName: lineName, week: '', boxType: '', page: index }, function (data) {
            $('#price_box').html(data);
        });
    }  
};
所以用zazor在后台组织数据返回的页面,也是可以实现ajax分页的





你可能感兴趣的:(asp.net)