1.PageIndexParameterName怎么关联?

答:其实就是Action里面的pageindex参数

例子:

@Html.Pager(Model, new PagerOptions {
PageIndexParameterName = "pageindex",
ShowPageIndexBox = true,
PageIndexBoxType = PageIndexBoxType.DropDownList,
ShowGoButton = false })

后台:

        public ActionResult Basic(int pageindex = )
{
return View(DemoData.AllArticles.OrderByDescending(a => a.PubDate).ToPagedList(pageindex, ));
}

2.输入页码无法跳转是怎么回事?

需要添加如下引用:

<script type="text/javascript" src="/Scripts/jquery-1.8.2.min.js"></script>

并通过如下方式注册MvcPager的客户端jQuery插件脚本:

@section Scripts{@{Html.RegisterMvcPagerScriptResource();}}

3.以下各节已定义,但尚未为布局页“~/Views/Shared/_Layout.cshtml”呈现:“Scripts”

嵌套的顶层应该写:

@RenderSection("Scripts", false)

误写成了:

@section Scripts{
@RenderSection("Scripts",false)
}

4.有关自定义路由

路由设置成这样:

            routes.MapRoute("Paging", "{controller}/{action}/page_{pageindex}", new { controller = "NoDb", action = "CustomRouting", pageindex =  }, new { action = "CustomRouting" });
routes.MapRoute("OptionalPaging", "{controller}/{action}/pageindex-{pageindex}", new { controller = "NoDb", action = "CustomRouting", pageindex = }, new { action = "CustomRouting" });

前台调用:

@Html.Pager(Model, new PagerOptions { ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false, FirstPageRouteName = "Default" }, "Paging")
@Html.Pager(Model, new PagerOptions { ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false, FirstPageRouteName = "Default" }, "OptionalPaging", null)

注意:如果第二个pager没有设置最后一个参数(routeValues)为null,则两个pager产生的路由信息完全相同,因为MVC中匹配到了第一个路由就把后面那个忽略了。

5.有关Ajax局部加载(不用PartialView的情况)

需要把EnablePartialLoading设为true,如:

@Ajax.Pager(Model,
new PagerOptions {
PageIndexParameterName = "id",
ShowPageIndexBox = true,
PageIndexBoxType = PageIndexBoxType.DropDownList,
ShowGoButton = false
},
new MvcAjaxOptions {
UpdateTargetId = "articles",
EnablePartialLoading = true
})

另外,如果按“下一页”,地址栏有变化,但是数据没有翻页翻过去,需要检查一下是不是BeginForm忘了加:

@Html.BeginForm()

复杂一点的:

@using (Html.BeginForm("AjaxPaging", "NoDb", new { id = "" }, FormMethod.Get, new { id = "searchForm" }))
{
<span>标题:</span>@Html.TextBoxFor(model => model.title, new { @id = "title", @name = "title", @type = "text", @style = "width:120px" })
<span>作者:</span>@Html.TextBoxFor(model => model.author, new { @id = "author", @name = "author", @type = "text", @style = "width:120px" })
<span>来源:</span>@Html.TextBoxFor(model => model.source, new { @id = "source", @name = "source", @type = "text", @style = "width:120px" })
<input type="submit" value="搜索(S)" accesskey="S" />
}

还有就是,Ajax.BeginForm在这里是行不通的

总的说来,这种方法只适合于简单的情况,还是把分页数据放到PartialView比较好

最新文章

  1. [转]Linux中configure/makefile
  2. authorization与URL授权
  3. Java04
  4. windows server 2008 配置安装AD 域控制器
  5. JS中delete删除对象属性
  6. 基于Solr实现HBase的二级索引
  7. 【C语言】10-字符和字符串常用处理函数
  8. NBOJv2 Problem 1009 蛤玮的魔法(二分)
  9. C++中new和delete来创建和释放动态数组
  10. 【锋利的JQuery-学习笔记】菜单栏及其2级菜单
  11. VS中批量删除cs代码中的#region和#endregion
  12. Trapping Raining Water 解答
  13. SolrCloud今日大纲
  14. IDEA+Maven配置MyBatis的初体验(坑点总结)
  15. 这是一个蒟蒻的计划……QAQ
  16. Jenkins结合.net平台综合之完整示例项目
  17. 【微服务目录】.NET Core 微服务介绍
  18. ceph存储集群测试方案
  19. POST数据中有特殊符号导致数据丢失的解决方法
  20. C# 编码标准(二)

热门文章

  1. Solr highlight
  2. jsp内置对象作用域白话演示
  3. html表格合并单元格的运用实例
  4. 9.数据分组 ---SQL
  5. [Java]HashSet的工作原理
  6. 用 scp 命令通过 SSH 互传文件
  7. 如何使用在Windows 下AspNetCore Api 和 consul
  8. springboot springmvc 抛出全局异常解决方法
  9. 常用的http网页错误代码表---------495引发的一个简单到爆,但基于国内环境只能呵呵呵的血案
  10. calibre电子书管理软件