本文实例为大家分享了jquery分页插件实现无刷新分页的相关代码,供大家参考,具体内容如下
1.使用插件为 jquery.pagination.js ,如果没有这个js文件的话,我可以给发个。
首先引用 jquery.pagination.js (分页js),跟pagination.css(分页样式css)。
点击获取查看这两个文件
2.页面js代码为
3.页面里面的代码为
商品名:
商品编号 商品名称
4.页面后台代码为
protected int pcount = 0; //总条数 protected void page_load(object sender, eventargs e) { if (!ispostback) { bll.tbgoods bll = new bll.tbgoods(); pcount = bll.getrecordcount(status=' + (int)enum.recordstatus.normal + '); //获取页面总条数,即要现实的数据总条数,还不明白的话,就是select count(*)from table ,就是这里的个数。 } }
5.一般处理程序fffff.ashx代码为
using system;using system.collections.generic;using system.linq;using system.web;using system.text;using system.data;namespace eshop.web.admin.tool.reserver{ /// /// listbuybatchmanage 的摘要说明 /// public class listbuybatchmanage : ihttphandler { public void processrequest(httpcontext context) { context.response.contenttype = text/plain; string str = string.empty; if (context.request[pageindex] != null && context.request[pageindex].tostring().length > 0) { int pageindex; //具体的页面数 int.tryparse(context.request[pageindex], out pageindex); if(context.request[pagesize]!=null&&context.request[pagesize].tostring().length > 0) { //页面显示条数 int size = convert.toint32(context.request[pagesize]); string data= bindsource(size,pageindex); context.response.write(data); context.response.end(); } } } #region 无刷新分页 public string bindsource(int pagesize,int page) { bll.tbgoods bll=new bll.tbgoods(); dataset ds = bll.getlistbypage(status=' + (int)enum.recordstatus.normal + ', , pagesize * page + 1, pagesize * (page + 1)); //获取数据源的ds会吧。 stringbuilder sb = new stringbuilder(); if (ds!=null) { foreach (datarow row in ds.tables[0].rows) { sb.append(); sb.append(row[goodsuid]); sb.append( ); sb.append(row[goodsname]); sb.append(
); } } return sb.tostring(); } #endregion public bool isreusable { get { return false; } } }}
6.效果图
以上就是本文的全部内容,希望对大家的学习有所帮助。