当前位置:文档之家› C#(.net)分页控件源码(已测试)

C#(.net)分页控件源码(已测试)

分页控件的用法align类:using System;namespace MyPaperControls{///<summary>/// Align 的摘要说明。

///</summary>public enum Align{Center = 0,Left = 1,Right = 2}}MyPager类:using System;using ponentModel;using System.Diagnostics;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Resources;using System.Collections;using System.Collections.Specialized;using System.Text;using System.Text.RegularExpressions;using System.Drawing;using pilerServices;using MyPaperControls.Designer;[assembly:TagPrefix("MyPaperControls", "MP")]namespace MyPaperControls{[ToolboxData("<{0}:MyPaper runat=server></{0}:MyPaper>"),ValidationPropertyAttribute("Text"),Designer(typeof(MyPaperControls.Designer.MyPaperDesigner)), DescriptionAttribute("跳转到此页面")][ParseChildren(true)][PersistChildren(false)]public class MyPaper : WebControl, INamingContainer,IPostBackDataHandler{string Pager_LinkButton_Left = "";string Pager_LinkButton_Right = "";string RPageNo ="";#region============设置连接数字==========================private string linknumberwidth = "10px";private string linknumbercssclass = "";private Color currentnumberbgcolor = Color.Red;private int leftpagesize = 5;private int rightpagesize = 5;[Category("控件连接数字"),DefaultValue("10px"),DescriptionAttribute("获取或设置连接数字区域宽度"),NotifyParentProperty(true)]public string LinkNumberWidth{get{return linknumberwidth;}set{linknumberwidth = value;}}[Category("控件连接数字"),DefaultValue("20px"),DescriptionAttribute("获取或设置连接数字css样式"),NotifyParentProperty(true)]public string LinkNumberCssClass{get{return linknumbercssclass;}set{linknumbercssclass = value;}}[Category("控件连接数字"),DefaultValue("#FF6600"),DescriptionAttribute("获取或设置当前连接数字的背景颜色"),NotifyParentProperty(true)]public Color CurrentNumberBgColor{get{return currentnumberbgcolor;}set{currentnumberbgcolor = value;}}[Category("控件连接数字"),DefaultValue(5),DescriptionAttribute("设置或获取分页左边要显示的页码数"),NotifyParentProperty(true)]public int LeftPageSize{get{return leftpagesize;}set{leftpagesize = value;}}[Category("控件连接数字"),DefaultValue(5),DescriptionAttribute("设置或获取分页右边要显示的页码数"),NotifyParentProperty(true)]public int RightPageSize{get{return rightpagesize;}set{rightpagesize = value;}}#endregion#region============设置连接文字或图片==========================private string firstlink = "第一页";private string previouslink = "上一页";private string nextlink = "下一页";private string lastlink = "最后一页";private string linktextcssclass = "";private bool linkistext = true;[Category("控件连接文字或图片"),DefaultValue(""),DescriptionAttribute("获取或设置链接文字或图片地址的CSS类名"),NotifyParentProperty(true)]public string LinkTextCssClass{get{return linktextcssclass;}set{linktextcssclass = value;}}[Category("控件连接文字或图片"),DefaultValue(""),DescriptionAttribute("获取或设置链接是否是文字或图片"),NotifyParentProperty(true)]public bool LinkIsText{get{return linkistext;}set{linkistext = value;}}[Category("控件连接文字或图片"),DefaultValue("第一页"),DescriptionAttribute("获取或设置第一页的文字或图片地址"),NotifyParentProperty(true)]public string FirstLink{get{return firstlink;}set{firstlink = value;}}[Category("控件连接文字或图片"),DefaultValue("上一页"),DescriptionAttribute("获取或设置上一页的文字或图片地址"),NotifyParentProperty(true)]public string PreviousLink{get{return previouslink;}set{previouslink = value;}}[Category("控件连接文字或图片"),DefaultValue("下一页"),DescriptionAttribute("获取或设置下一页的文字或图片地址"),NotifyParentProperty(true)]public string NextLink{get{return nextlink;}set{nextlink = value;}}[Category("控件连接文字或图片"),DefaultValue("最后一页"),DescriptionAttribute("获取或设置最后一页的文字或图片地址"),NotifyParentProperty(true)]public string LastLink{get{return lastlink;}set{lastlink = value;}}#endregion#region===============初始相关函数=============protected override void OnInit( EventArgs e ){GetFormClientID();base.OnInit(e);}private string GetFormClientID(){if(IsHtmlForm(this.Parent)){return this.Parent.ClientID;}Control c = this.Parent;while(c != null){c = c.Parent;if(IsHtmlForm(c)){return c.Parent.ClientID;}}throw new Exception(string.Format("类型“{1}”的控件“{0}”必须放在具有runat=server 的窗体标记内。

相关主题