asp.net MVC 异步分页 PagedList
最近做一个项目要有的异步分页,先记录下来!
引用:
PagedList.css
MvcPager.js
<link href="~/css/sweetalert2.min.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/js/sweetalert2.min.js"></script>
<script src="~/js/pikaday.min.js"></script>
sweetalert2:弹框插件
pikaday:时间插件
1、表单
<div class="manuscript-mutual pages-manus">
<div class="content--top clearfix task-management--top">
@using (Ajax.BeginForm("TaskManagement",
new RouteValueDictionary { { "id", "" } },
new AjaxOptions
{
UpdateTargetId = "taskManagementId",
HttpMethod = "Get",
InsertionMode = InsertionMode.Replace,
OnBegin = "tmonBegin",
OnSuccess = "tmonSuccess"
},
new RouteValueDictionary { { "id", "taskManagementForm" } }))
{
<div class="fl">
<p class="p-content">
<input type="text" id="sTimea" name="sTimea" placeholder="开始时间" class="time" readonly="readonly" />
</p>
<p class="p-margin">到</p>
<p class="p-content">
<input type="text" id="eTimea" name="eTimea" placeholder="结束时间" class="time" readonly="readonly" />
</p> <p class="search--time">
<button class="search-time"><span>按日期检索</span></button>
</p>
</div> <div class="content-whole clearfix fr">
<img src="/img/whole.png" alt="" class="fl" />
<input class="whole-btn whole-search fl" type="submit" id="taskManagementid" value="全部显示" />
</div>
} </div>
<div class="task-management--bottom" id="taskManagementId">
@Html.Partial("_MyReleased", Model.ArticleList1)
</div>
</div>
@section Scripts
{@{Html.RegisterMvcPagerScriptResource();}
<script type="text/javascript" src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>}
id:页码,用于传递页码数
taskManagementId:用于异步刷新内容,这地方坑我好多时间。
@using Webdiyer.WebControls.Mvc;
@model Webdiyer.WebControls.Mvc.PagedList<Entity.MissionProgress> <ul class="clearfix">
@foreach (var item in Model)
{
<li class="fl clearfix">
@{ string imgurl = string.IsNullOrEmpty(item.MissionList.MediaUnits.img) ? "/img/test.jpg" : item.MissionList.MediaUnits.img;}
<img src="@imgurl" alt="" class="head-img fl" />
<div class="task-management--list fl">
<h3>@item.MissionList.name</h3>
<p class="content-abs">@item.MissionList.claims</p>
<div class="task-management--time">
<img src="/img/s-time.png" alt="" />
@item.MissionList.startDateTime —— @item.MissionList.endDateTime
</div>
</div>
<div class="fl gold-media">
<p>目标媒体<em>@missionListIdCount 个</em></p>
<p><em>@executeType0</em>个未领取任务</p>
<p><em>@executeType1</em>个正在执行任务</p>
<p><em>@executeType2</em>个已完成任务</p>
</div>
<div class="fl task-btn">
@{
int? executeType = item.executeType;
string typetext = string.Empty;
switch (executeType)
{
case 0:
typetext = "领取任务";
break;
case 1:
typetext = "正在执行";
break;
case 2:
typetext = "已完成";
break;
default:
typetext = "领取任务";
break;
}
}
<button class="fr task-btn--ing ">@typetext</button>
</div>
</li>
}
</ul> <div class="list-page clearfix task-list--page">
<div class="list-page--ct fr clearfix">
@Ajax.Pager(Model, new PagerOptions
{
FirstPageText = "首页",
PrevPageText = "上一页",
NextPageText = "下一页",
LastPageText = "尾页",
PageIndexParameterName = "id",
ContainerTagName = "div",
CssClass = "pagination",
CurrentPagerItemTemplate = "<span class=\"current\">{0}</span>",
DisabledPagerItemTemplate = "<span class=\"disabled\">{0}</span>",
Id = "badoopager",
}).AjaxOptions(a => a.SetUpdateTargetId("taskManagementId").SetDataFormId("taskManagementForm"))
</div>
</div>
asp.net MVC 异步分页 PagedList的更多相关文章
- 学习ASP.NET MVC(十一)——分页
在这一篇文章中,我们将学习如何在MVC页面中实现分页的方法.分页功能是一个非常实用,常用的功能,当数据量过多的时候,必然要使用分页.在今天这篇文章中,我们学习如果在MVC页面中使用PagedList. ...
- asp.net mvc异步查询
对于asp.net mvc异步查询 如何做MVC异步查询,做列表页面. 查询是项目中必不可少的工作,而且不同的项目不同的团队,都有自己的简单方法.Asp.net mvc 有自己独特的优势,下面是结合m ...
- c#异步编程(三)—ASP.NET MVC 异步控制器及EF异步操作
ASP.NET MVC 异步控制器及EF异步操作 异步控制器 ASP.NET MVC2后开始了对异步请求管道的支持,异步请求管道的作用是允许web服务器处理长时间运行的请求,比如 那些花费大量时间等待 ...
- ASP.NET MVC异步验证是如何工作的03,jquery.validate.unobtrusive.js是如何工作的
在上一篇"ASP.NET MVC异步验证是如何工作的02,异步验证表单元素的创建"中了解了ASP.NET异步验证是如何创建表单元素的,本篇体验jquery.validate.uno ...
- ASP.NET MVC异步验证是如何工作的02,异步验证表单元素的创建
在上一篇"ASP.NET MVC异步验证是如何工作的01,jQuery的验证方式.错误信息提示.validate方法的背后"中,了解了jQuery如何验证,如何显示错误信息,本篇要 ...
- ASP.NET MVC异步验证是如何工作的01,jQuery的验证方式、错误信息提示、validate方法的背后
ASP.NET MVC借助jQuery的验证机制,提供了一套从客户端到服务端异步验证的解决方案,通常情况下,用起来相当方便.但面对一些相对特殊的情况,可能会遇到验证失效的场景,比如在使用ajax动态异 ...
- ASP.NET MVC 简单分页代码
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- asp.net MVC通用分页组件 使用方便 通用性强
asp.net MVC通用分页组件 使用方便 通用性强 该分页控件的显示逻辑: 1 当前页面反色突出显示,链接不可点击 2 第一页时首页链接不可点击 3 最后一页时尾页链接不可点击 4 当前页面左 ...
- Asp.net MVC 简单分页 自做简单分页
Asp.net MVC 简单分页: public static string Pager(int page,int pageSize,int total) { ...
随机推荐
- 微信小程序 wxParse插件显示视频
修改wxParse/html2json.js 文件 ,在 html2json(html, bindName) 方法里 var node = { node: 'element', tag: tag, } ...
- 常见的可以写入VIM配置文件中的设置参数
常见的可以写入.vimrc文件中的设置参数 设置参数 含义 :set nu :set nonu 设置与取消行号 :syn on :syn off 是否依据语法显示相关的颜色帮助,在VIM修改相关的配置 ...
- easyUI的datagrid表格的使用
实现easyUI表格的里面数据的增删改查功能.SQL使用Oracle和mybatis. 话不多说,直接上代码. 首先是前段部分的. var session = GetSession(); var pa ...
- what should I use .post vs .ajax?
what should I use .post vs .ajax? 问题: I've always had this dilemma困境 whether to use .post or .ajax f ...
- API 设计 POSIX File API
小结: 1. https://mp.weixin.qq.com/s/qWrSyzJ54YEw8sLCxAEKlA API 设计最佳实践的思考 谷朴 阿里技术 昨天 阿里妹导读:API 是模块或者子 ...
- ArcGIS 10.5 tensorflow安装日记
ArcGIS 10.5 tensorflow安装日记 商务科技合作:向日葵,135-4855__4328,xiexiaokui#qq.com Datetime: 2019年5月27日星期一 Os: w ...
- lua 求table长度和判断空
local table_a = {} 判断一:(错误方法) if table_a == {} then --你会发现你怎么也进不来 条件判断始终返回false,为什么会这样呢? ...
- Greenwich.SR2版本的Spring Cloud Ribbon实例
上次我们了解了eureka(参见Greenwich.SR2版本的Spring Cloud Eureka实例),里面的服务消费方(服务实例a-beautiful-client)我们其实已经用到了ribb ...
- webpack——Modules && Hot Module Replacement
blog:JavaScript Module Systems Showdown: CommonJS vs AMD vs ES2015 官网链接: Modules 官网链接:Hot Module Rep ...
- sql 获取本周周一和周日
版本1.0(获取周日存在问题,请勿使用,仅用于引以为戒) 存在问题,获取周日的时候,当当前时间正好是周日,会获取下一周的周日,而非本周周日. ,)),) ),, ,)),) 版本2.0 看到版本1.0 ...