1.Nuget包添加引用: X.PagedList.Mvc.Core

2.View: 

@using VipSoft.Web.Model
@model X.PagedList.IPagedList<VipSoft.Web.Model.DBEntity.Job>
@using X.PagedList.Mvc.Core; <h1>社会招聘 职位搜索</h1>
<form asp-action="JobInfo" method="get" class="form-inline" role="form">
@Html.TextBox("searchKey", ViewData["SearchKey"] as string, htmlAttributes: new { @class = "form-control", placeHolder = "请输入职业关键词、背景专业名称" })
<input type="submit" value="搜索" class="btn btn-primary" />
</form> @foreach (var item in Model)
{
<div class="row m_t100">
<div class="col-md-7">
<p class="co_news_title m_t30">@item.Position</p>
<p class="co_news_abstract m_t20">
所属部门: @item.Department 工作地点: @item.Locations
<br />
描述:@item.Description
</p>
</div>
</div>
} @Html.PagedListPager(Model, page => Url.Action("JobInfo", new { page, searchKey = ViewData["SearchKey"] }))

3.Controller

using X.PagedList;
public IActionResult JobInfo(string searchKey, int page = 1, int pageSize = 10)
{
ViewData["PageSize"] = pageSize;
ViewData["SearchKey"] = searchKey;
List<Job> result = jobService.ListJob(); //可以把参数带到后台,我这边数据量小,直接全部全取在客户端分页的
if (!string.IsNullOrEmpty(searchKey))
{
result = result.Where(s => (!string.IsNullOrEmpty(s.Position) && s.Position.Contains(searchKey))
|| (!string.IsNullOrEmpty(s.Locations) && s.Locations.Contains(searchKey))
|| (!string.IsNullOrEmpty(s.PositionType) && s.PositionType.Contains(searchKey))).ToList();
}
return View(result.ToPagedList(page, pageSize));
}

Asp.Net Core 使用X.PagedList.Mvc.Core分页 & 搜索的更多相关文章

  1. Asp.net MVC 使用PagedList(新的已更名 为X.PagedList.Mvc) 分页

    在asp.net mvc 中,可以bootstrap来作为界面,自己来写分页程序.也可以使用PagedList(作者已更名为 X.PagedList.Mvc)来分页. 1.首先,在NuGet程序包管理 ...

  2. asp.net MVC 使用PagedList.MVC实现分页

    在上一篇的EF之DB First中,存在以下的两个问题: 1. 添加/编辑页面显示的是属性名称,而非自定义的名称(如:姓名.专业...) 2. 添加/编辑时没有加入验证 另外数据展示使用分页 @Htm ...

  3. 再谈使用X.PagedList.Mvc 分页(ASP.NET Core 2.1)

    在以前的博文中写过使用X.PagedList.Mvc组件来对ASP.NET MVC应用程序进行分页,可以参考此篇随笔:Asp.net MVC 使用PagedList(新的已更名 为X.PagedLis ...

  4. 学习ASP.NET Core Razor 编程系列十九——分页

    学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二——添加一个实体 学习ASP.NET ...

  5. ASP.NET MVC 4使用PagedList.Mvc分页

    ASP.NET MVC中进行分页的方式有多种,在NuGet上有提供使用PagedList.PagedList.Mvc进行分页. 1. 通过NuGet引用PagedList.Mvc 在安装引用Paged ...

  6. ASP.NET/MVC/Core的HTTP请求流程

    ASP.NET HTTP管道(Pipeline)模型 1. 先讲一点,再深刻思考 一般我们都在写业务代码,优化页面,优化逻辑之间内徘徊.也许我们懂得HTTP,HTTPS的GET,POST,但是我们大部 ...

  7. ASP.NET Core中使用自定义MVC过滤器属性的依赖注入

    除了将自己的中间件添加到ASP.NET MVC Core应用程序管道之外,您还可以使用自定义MVC过滤器属性来控制响应,并有选择地将它们应用于整个控制器或控制器操作. ASP.NET Core中常用的 ...

  8. .NET CORE学习笔记系列(1)——ASP.NET MVC Core 介绍和项目解读

    ASP.NET MVC Core 项目文件夹解读 一.项目文件夹总览 1.1.Properties——launchSettings.json 启动配置文件,你可以在项目中“Properties”文件夹 ...

  9. ASP.NET Core 1.0、ASP.NET MVC Core 1.0和Entity Framework Core 1.0

    ASP.NET 5.0 将改名为 ASP.NET Core 1.0 ASP.NET MVC 6  将改名为 ASP.NET MVC Core 1.0 Entity Framework 7.0    将 ...

  10. [转帖]2016年时的新闻:ASP.NET Core 1.0、ASP.NET MVC Core 1.0和Entity Framework Core 1.0

    ASP.NET Core 1.0.ASP.NET MVC Core 1.0和Entity Framework Core 1.0 http://www.cnblogs.com/webapi/p/5673 ...

随机推荐

  1. 高精度加法(C语言实现)

    高精度加法(C语言实现) 介绍 众所周知,整数在C和C++中以int ,long,long long三种不同大小的数据存储,数据大小最大可达2^64,但是在实际使用中,我们仍不可避免的会遇到爆long ...

  2. [Python急救站]草莓熊的绘制

    草莓熊也是一个热门的图案,今天就用Python绘制一下 import turtle as t # 设置背景颜色,窗口位置以及大小 t.colormode(255) # 颜色模式 t.speed(0) ...

  3. 03Java学习_注释和代码规范

    注释和代码规范 目录 注释和代码规范 注释 注释介绍 单行注释 多行注释 文档注释 代码规范 注释 注释介绍 用于注解说明解释程序的文字就是注释,注释提高了代码的阅读性(可读性):注释 是一个程序员必 ...

  4. Echarts 饼图,legend样式美化

    最后样式图: 实现代码: var myChart = echarts.init(document.getElementById('container')); let option = { /*{b}: ...

  5. base64编码的学习

    base64编码是什么 Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,Base64就是一种基于64个可打印字符来表示二进制数据的方法. Base64编码本质上是一种将二进制数据转成 ...

  6. Modbus转Profinet 网关

    产品简介 实现 PROFINET 网络与串口网络之间的数据通信,三个串口可分别连接具有 RS232 或 RS485 接口的设 备到 PROFINET 网络.即将串口设备转换为 PROFINET 设备. ...

  7. vue + node 前后端分离项目解决跨域问题

    vue + node 前后端分离项目解决跨域问题 由于前端 和 后端 项目运行于不同端口,无法直接传递数据 后端 app.js 添加如下代码 var cors = require('cors') ap ...

  8. MyBatis-Plus雪花算法实现源码解析

    1. 雪花算法(Snowflake Algorithm) 雪花算法(Snowflake Algorithm)是一种用于生成唯一标识符(ID)的分布式算法.最初由 Twitter 公司开发,用于生成其内 ...

  9. springBoot——整合junit

    spring整合junit复习 springBoot整合junit package com.example.springboot_04; import com.example.springboot_0 ...

  10. POJ1006、hdu1370

    思路:中国剩余定理.纯粹的用暴力求逆元. 1 #include<iostream> 2 #include<string.h> 3 #include<string> ...