前端代码
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Comp_Paging.ascx.cs" Inherits="Inc_Comp_Comp_Paging" %> <style type="text/css"> #Page_Tale { margin: 20px auto; } </style> <table width="100%" border="0" cellspacing="0" cellpadding="0" id="Page_Tale"> <tr> <td align="center"> 每页 <%=this.PageSize%>条 共 <%=this.RecordCount%>条 <%=this.PageCount%>页 <span CY_Hover="1"> <span class="cy_Link1" CY_HoverClass="cy_Link1_ove" <% if(PageIndex == 0){ %> style="color:#ccc;" disabled="disabled" <%} else{ %>onclick="<%=this.PagingJaveScript %>(‘0‘)" <% } %>> 首页 </span></span><span style="width:5px;"></span> <span CY_Hover="1"><span class="cy_Link1" CY_HoverClass="cy_Link1_ove" <% if(PageIndex == 0){ %> style="color:#ccc;" disabled="disabled" <%} else{ %> onclick="<%=this.PagingJaveScript%>(‘<%=this.PageIndex-1 < 0 ? 0 : this.PageIndex-1 %>‘)" <% } %>>上页</span></span> <span style="width:5px;"></span> <%--<input type="text" class="cy_TextBox" value="<%=this.PageIndex + 1%>" onkeypress="if(event.keyCode==13){var tempV=this.value;if($cy.Check.IsInt(tempV)){if(tempV/1> <%=this.PageCount%>){tempV=‘ <%=this.PageCount%>‘;}}else{tempV=‘0‘} <%=this.PagingJaveScript%>(tempV/1-1);}" style="width:30px; text-align:center" />--%> <select data-role="none" onchange="var tempV=this.value-1;<%=this.PagingJaveScript%>(tempV)" style="width:50px; text-align:center"> <% for (int select_index = 1; select_index <= this.PageCount; select_index++) { if (select_index == PageIndex+1) { %> <option value="<%=select_index%>" selected="selected"><%= select_index %></option> <% } else { %> <option value="<%=select_index%>" ><%= select_index %></option> <% } } %> </select> <span CY_Hover="1"><span class="cy_Link1" CY_HoverClass="cy_Link1_ove" <% if (this.PageIndex + 1 == this.PageCount){ %> style="color:#ccc;" disabled="disabled" <%}else{ %> onclick="<%=this.PagingJaveScript%>(‘<%=this.PageIndex + 1 >= this.PageCount ? this.PageCount - 1 : this.PageIndex + 1%>‘)" <% } %>> 下页 </span></span><span style="width:5px;"></span> <span CY_Hover="1"><span class="cy_Link1" CY_HoverClass="cy_Link1_ove" <% if(this.PageIndex +1 == this.PageCount){ %> style="color:#ccc;" disabled="disabled" <%} else{ %> onclick="<%=this.PagingJaveScript%>(‘<%=this.PageCount-1%>‘)" <% } %>> 尾页 </span></span><span style="width:5px;"></span> </td> </tr> </table>
组件代码:
using System; public partial class Inc_Comp_Comp_Paging : System.Web.UI.UserControl { private int _PageCount = 0; public int PageCount #region { set { this._PageCount = value; } get { return this._PageCount; } } #endregion private int _PageIndex = 0; public int PageIndex #region { set { this._PageIndex = value; } get { return this._PageIndex; } } #endregion private int _PageSize = 0; public int PageSize #region { set { this._PageSize = value; } get { return this._PageSize; } } #endregion private int _RecordCount = 0; public int RecordCount #region { set { this._RecordCount = value; } get { return this._RecordCount; } } #endregion private string _PagingJaveScript = "$cy.tp.Paging"; public string PagingJaveScript #region { set { this._PagingJaveScript = value; } get { return this._PagingJaveScript; } } #endregion protected void Page_Load(object sender, EventArgs e) { // } }
后端代码:
this.Paging_1.PageCount = page_num; this.Paging_1.PageSize = Rows; this.Paging_1.PageIndex = PageIndex; this.Paging_1.RecordCount = RecordCount; if (this.Paging_1.RecordCount > 0) { this.Paging_1.Visible = true; } else { this.Paging_1.Visible = false; } if (this.Paging_1.PageSize == SiteConfig.NoPagingPageSize) { this.Paging_1.Visible = false; }
时间: 2024-10-04 02:51:31