当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET MVC分页问题解决

ASP.NET MVC分页问题解决

2017年12月12日  | 移动技术网IT编程  | 我要评论

搞笑小品大全,亲子教育巧虎 官网,无限奇迹

在使用ajax.pager进行分页的时候需要注意一下几个方面:

  1、一定要引入jquery.unobtrusive-ajax.min.js这个js;

  2、一定要在页面中使用注册分页器,注册方法:@{html.registermvcpagerscriptresource();};

具体的使用方法示例:

<div class="row" style="position: relative; left: 30%">
  <div class="col-md-8" style="width: auto">
    @{
      pagerconfig pagerconfig = new pagerconfig("pageindex", "pageindexbox", "gotobtn");
      pageroptions options = pagerconfig.getpageroption();
    }
    @ajax.pager(model, options).ajaxoptions(a => a.setupdatetargetid("articles").sethttpmethod("post").setdataformid("searchview"))
  </div>
  <div class="col-md-4">
    <div class="input-group" style="width: 120px; margin: 20px 0">
      <input type="text" id="pageindexbox" class="form-control" />
      <span class="input-group-btn"><button class="btn btn-primary" id="gotobtn">跳转</button></span>
    </div>
  </div>
</div>

其中model是ipagedlist对象,获取pageroptions的方法如下:

/// <summary>
    /// 翻页配置项
    /// </summary>
    /// <returns></returns>
    public pageroptions getpageroption()
    {
      pageroptions options = new pageroptions
      {
        autohide = false,
        firstpagetext = "首页",
        lastpagetext = "尾页",
        nextpagetext = "下一页",
        prevpagetext = "上一页",
        pageindexparametername = this._pageindexparaname,
        containertagname = "ul",
        cssclass = "pagination",
        currentpageritemtemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
        disabledpageritemtemplate = "<li class=\"disabled\"><a>{0}</a></li>",
        pageritemtemplate = "<li>{0}</li>",
        pageindexboxid = this._pageindexboxid,
        gotobuttonid = this._gotobuttonid,
        numericpageritemcount = 5
      };

      return options;
    }

目前所知,该控件不支持显示记录总数及总页数。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网