一、.ascx页面
代码如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Pagination.ascx.cs" Inherits="IOCS.WEB.UserControl.Pagination" %>
<link href="../Content/Css/Pager.css" rel="stylesheet" type="text/css" />
<div id="tbPage" class="pager" runat="server" >
記錄總數:<asp:Label ID="LRecords" runat="server"></asp:Label>
總頁數:<asp:Label ID="LPages" runat="server"></asp:Label>
當前頁:<asp:Label ID="LPage" runat="server"></asp:Label>
<asp:LinkButton ID="LinkFirst" runat="server" CommandArgument="first" nClick="PagerButtonClick"
Text="首頁"></asp:LinkButton>
<asp:LinkButton ID="LinkPrevious" runat="server" CommandArgument="prev" nClick="PagerButtonClick"
Text="上一頁"></asp:LinkButton>
<asp:LinkButton ID="LinkNext" runat="server" CommandArgument="next" nClick="PagerButtonClick"
Text="下一頁"></asp:LinkButton>
<asp:LinkButton ID="LinkLast" runat="server" CommandArgument="last" nClick="PagerButtonClick"
Text="末頁"></asp:LinkButton>
轉到第<asp:TextBox ID="txtpage" CssClass="piut" runat="server" MaxLength="5" AutoPostBack="True" nTextChanged="txtpage_TextChanged"></asp:TextBox>頁
二、.ascx.cs文件
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace IOCS.WEB.UserControl
{
public partial class Pagination : System.Web.UI.UserControl
{
public event EventHandler PageButtonClick;
public bool FirstPost = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
// 只輸入數字
txtpage.Attributes.Add("onclick",
@"if(!((event.keyCode>=48&&event.keyCode<=57)
新闻热点
疑难解答
图片精选