快捷搜索:

无刷新分页实现代码_jquery_脚本之家

2019-11-26 作者:白姐四不像必中一肖图   |   浏览(86)

控件类代码: 复制代码 代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Reflection; using System.IO; [assembly: WebResource("PageBarJS.js", "application/x-javascript")] namespace Hawkon.Control { [DefaultProperty] [ToolboxData("{0}:PageBar>")] public class PageBar : WebControl { [Bindable] [Category] [DefaultValue] [Localizable] public int PageIndex { get { return pageIndex; } set { pageIndex = value; } } private int pageIndex; [Bindable] [Category] [DefaultValue] [Localizable] public int PageCount { get { return pageCount; } set { pageCount = value; } } private int pageCount; [Bindable] [Category] [DefaultValue] [Localizable] public int DisplayCount { get { return displayCount; } set { displayCount = value; } } private int displayCount; protected override void RenderContents(HtmlTextWriter output) { string html = ""; html += CreateA; int b = 0, e = 0; if (pageIndex <= displayCount) { b = 1; e = displayCount * 2 + 1; } else if (pageIndex > pageCount - displayCount) { b = pageCount - displayCount * 2; e = pageCount; } else { b = pageIndex - displayCount; e = pageIndex + displayCount; } if { html += CreateA; } else html += CreateA; for (int i = b; i <= e; i++) { html += CreateA; } html += CreateA; html += CreateA; // html += string.Format("

", // this.Page.ClientScript.GetWebResourceUrl, "JScript1.js")); output.Write; } private string CreateA(int pageIndex, string text) { if (pageIndex == this.pageIndex) { return string.Format("{1}", pageIndex, text); } return string.Format("{1}", pageIndex, text); } protected override void OnPreRender { base.OnPreRender; string resourceName = "PageBarJS.js"; string url = this.Page.ClientScript.GetWebResourceUrl, "PageBarJS.js"); string script = "rn

"; this.Page.ClientScript.RegisterClientScriptBlock, resourceName, script, false); script = @"

"; this.Page.ClientScript.RegisterClientScriptBlock, "ready", script); } protected override void Render(HtmlTextWriter writer) { base.Render; } } } JS资源文件代码: 复制代码 代码如下: var displayCount; var getDataUrl; var bookTableId; var currentIndex; var pageCount; var linkClass; var fields; function InitPageBar { displayCount = dc; getDataUrl = gdu; bookTableId = btId; currentIndex = 1; pageCount = pc; linkClass = "."+lc; $.click; } function GetPageById.val; var surl = getDataUrl+"?pageIndex=" + id; $.ajax({ url: surl, type: "GET", dataType: "json", timeout: 1000, success: showResult } ); } function GetPage() { GetPageById; } function showResult { for (i = 1; i <= result.Data.length; i++) { var id = "#" + bookTableId + " tr:nth-child"; obj = result.Data[i - 1]; for { ctl = $; if { ctl.get.innerHTML = obj[key]; } } } $.each { var i, b, e; if (result.CurrentPageIndex <= displayCount) { b = 1; e = * 2; i = index - 2 + 1; } else if (result.CurrentPageIndex > pageCount - displayCount) { b = pageCount - displayCount * 2; e = pageCount; i = pageCount - displayCount * 2 + index - 2; } else { i = result.CurrentPageIndex - displayCount + index - 2; b = result.CurrentPageIndex - displayCount - 1; e = result.CurrentPageIndex

  • displayCount + 1; } if .id == $ { $; } else if { if .get.id = 1; } else { $.id = b - 1; } } else if (index == displayCount * 2 + 3) { $.id = e; } $.attr; if { $.id = i; } if .text == result.CurrentPageIndex) { $.removeAttr; currentIndex = result.CurrentPageIndex; } HTML页面代码: 复制代码 代码如下: Ajax请求地址返回的JSON数据: 复制代码 代码如下: {"Data":[{"Title":"C#.NET程序设计——国外计算机科学经典教材","CategoryName":".NET","Author":"布拉德利,米尔斯波 着, 天宏工作室 译","Id":5392},{"Title":"C#2.0〔宝典)","CategoryName":"C C++ VC VC++","Author":"张立 编着","Id":5027},{"Title":"C#2.0完全自学手册","CategoryName":"C C++ VC VC++","Author":"张立 等编着","Id":5081},{"Title":"C#2005数据库编程经典教程","CategoryName":"C C++ VC VC++","Author":" 着,陈秋萍 译","Id":4983},{"Title":"C#程序设计教程——计算机基础课程系列教材","CategoryName":"C C++ VC VC++","Author":"郑阿奇,梁敬东 主编","Id":5127},{"Title":"C#程序员参考手册","CategoryName":"C C++ VC VC++","Author":"Grant Palmer 着,康博 译","Id":5132},{"Title":"C#和.NET核心技术——开发人员专业技术丛书","CategoryName":"C C++ VC VC++","Author":" 着,肖斌 等译","Id":5104},{"Title":"C#基础与实例教程","CategoryName":"C C++ VC VC++","Author":"郝春强 编着","Id":5071},{"Title":"C#软件项目开发全程剖析","CategoryName":"C C++ VC VC++","Author":"斯普达 着,薛兴涛,袁勤勇 译","Id":5034},{"Title":"C#设计模式——开发大师系列","CategoryName":"C C++ VC VC++","Author":"麦斯科 着,颜炯 译","Id":4954}],"CurrentPageIndex":15,"PageCount":1074}

本文由正版香港马报免费资料发布于白姐四不像必中一肖图,转载请注明出处:无刷新分页实现代码_jquery_脚本之家

关键词: