www.pudn.com > WebPager.rar > SimplePager.cs, change:2005-01-25,size:2521b


using System; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
namespace Hooyee.WebControls { 
	/// <summary> 
	/// 翻页控件。演示用。 
	/// </summary> 
	public sealed class SimplePager : DataPagerBase { 
		public SimplePager() { 
		} 
 
		/// <summary> 
		/// 呈现控件内容。 
		/// </summary> 
		/// <param name="control">包含翻页控件的控件对象。</param> 
		public override void Render( Control control ) { 
			int curPageIndex = PagerInfo.PageIndex; 
			control.Controls.Clear(); 
 
			// 首页 
			control.Controls.Add( GetSpace(2) ); 
			if ( curPageIndex <= 0 ) { 
				Literal lFirst = new Literal(); 
				lFirst.Text = "<font color='#9A9A9A'>首页</font>"; 
				control.Controls.Add( lFirst ); 
			} else { 
				Control cFirst = CreateGotoPageLink( "首页" , PagerInfo.FirstIndex, "FirstIndex" ); 
				control.Controls.Add( cFirst ); 
			} 
 
			// 上一页 
			control.Controls.Add( GetSpace(2) ); 
			if ( curPageIndex <= 0 ) { 
				Literal lPrev = new Literal(); 
				lPrev.Text = "<font color='#9A9A9A'>上一页</font>"; 
				control.Controls.Add( lPrev ); 
			} else { 
				Control cPrev = CreateGotoPageLink( "上一页" , PagerInfo.PreIndex, "PreIndex" ); 
				control.Controls.Add( cPrev ); 
			} 
 
			// 下一页 
			control.Controls.Add( GetSpace(2) ); 
			if ( curPageIndex >= PagerInfo.LastIndex ) { 
				Literal lNext = new Literal(); 
				lNext.Text = "<font color='#9A9A9A'>下一页</font>"; 
				control.Controls.Add( lNext ); 
			} else { 
				Control cNext = CreateGotoPageLink( "下一页" , PagerInfo.NextIndex, "NextIndex" ); 
				control.Controls.Add( cNext ); 
			} 
 
			// 尾页 
			control.Controls.Add( GetSpace(2) ); 
			if ( curPageIndex >= PagerInfo.LastIndex ) { 
				Literal lLast = new Literal(); 
				lLast.Text = "<font color='#9A9A9A'>尾页</font>"; 
				control.Controls.Add( lLast ); 
			} else { 
				Control cLast = CreateGotoPageLink( "尾页" , PagerInfo.LastIndex, "LastIndex" ); 
				control.Controls.Add( cLast ); 
			} 
 
			// 页次 
			control.Controls.Add( GetSpace(2) ); 
			Literal lPage = new Literal(); 
			lPage.Text = string.Format( "<font color='#9A9A9A'>页次:<B>{0}</B>/<B>{1}</B>页</font>" 
				, curPageIndex + 1 , PagerInfo.PageCount ); 
			control.Controls.Add( lPage ); 
 
			// 篇数 
			control.Controls.Add( GetSpace(2) ); 
			Literal lItem = new Literal(); 
			lItem.Text = string.Format( "<font color='#9A9A9A'>共<B>{0}</B>篇  每页<B>{1}</B>篇</font>" , 
				PagerInfo.ItemCount , PagerInfo.PageSize ); 
			control.Controls.Add( lItem ); 
		} 
	} 
}