问题描述
下面的复合控件的源码usingSystem;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.ComponentModel;usingSystem.Drawing;namespaceAspNetPager{[DefaultProperty("BackColor"),ToolboxData("<{0}:Pagerrunat="server"></{0}:Pager>")]publicclassDataPager:System.Web.UI.WebControls.WebControl{privateColorfontColor=Color.FromArgb(255,102,0);privateLabellblCurrentPage=newLabel();privateLabellblPageCount=newLabel();privateLabellblPageSize=newLabel();privateLabellblRecordCount=newLabel();privateLinkButtonlbFirstPage=newLinkButton();privateLinkButtonlbForePage=newLinkButton();privateLinkButtonlbNextPage=newLinkButton();privateLinkButtonlbLastPage=newLinkButton();privateDropDownListddlGoPage=newDropDownList();privatePaneldivPanel=newPanel();privateintcurrentPage;privatebytepageSize;privateintpageCount;privateintrecordCount;privateeventEventHandlerFirstPageOnClick;privateeventEventHandlerForePageOnClick;privateeventEventHandlerNextPageOnClick;privateeventEventHandlerLastPageOnClick;privateeventEventHandlerGoPageChange;publicDataPager(){lbFirstPage.Text="首页";lbForePage.Text="上一页";lbNextPage.Text="下一页";lbLastPage.Text="尾页";lbFirstPage.Click+=newEventHandler(this.FirstPage_Click);lbForePage.Click+=newEventHandler(this.ForePage_Click);lbNextPage.Click+=newEventHandler(this.NextPage_Click);lbLastPage.Click+=newEventHandler(this.LastPage_Click);ddlGoPage.SelectedIndexChanged+=newEventHandler(this.GoPage_SelectedIndexChanged);this.Controls.Add(this.lblCurrentPage);this.Controls.Add(this.lblPageCount);this.Controls.Add(this.lblPageSize);this.Controls.Add(this.lblRecordCount);this.Controls.Add(this.lbFirstPage);this.Controls.Add(this.lbForePage);this.Controls.Add(this.lbNextPage);this.Controls.Add(this.lbLastPage);this.Controls.Add(this.ddlGoPage);this.Controls.Add(this.divPanel);}//字体颜色属性[Bindable(false),Category("Appearance"),DefaultValue("")]publicoverrideColorForeColor{set{this.fontColor=value;}}[Bindable(false),Category("Appearance"),DefaultValue("")]publicintCurrentPage{set{this.currentPage=value;}}[Bindable(false),Category("Appearance"),DefaultValue("")]publicbytePageSize{set{this.pageSize=value;}}[Bindable(false),Category("Appearance"),DefaultValue("")]publicintRecordCount{set{this.recordCount=value;}}[Bindable(false),Category("Appearance"),DefaultValue("")]publicintPageCount{set{this.pageCount=value;}}protectedoverridevoidRender(HtmlTextWriteroutput){this.divPanel.RenderBeginTag(output);output.Write("第");this.lblCurrentPage.ForeColor=this.fontColor;this.lblCurrentPage.Text=currentPage.ToString();this.lblCurrentPage.RenderControl(output);output.Write("/");this.lblPageCount.ForeColor=this.fontColor;this.lblPageCount.Text=pageCount.ToString();this.lblPageCount.RenderControl(output);output.WriteLine("页");output.Write("共");this.lblRecordCount.ForeColor=this.fontColor;this.lblRecordCount.Text=recordCount.ToString();this.lblRecordCount.RenderControl(output);output.WriteLine("条信息");PageNavigation();this.lbFirstPage.RenderControl(output);output.WriteLine();this.lbForePage.RenderControl(output);output.WriteLine();this.lbNextPage.RenderControl(output);output.WriteLine();this.lbLastPage.RenderControl(output);output.WriteLine();for(inti=0;i<pageCount;i++){ddlGoPage.Items.Add(newListItem(i.ToString(),i.ToString()));}ddlGoPage.SelectedIndex=currentPage-1;this.ddlGoPage.RenderControl(output);this.divPanel.RenderEndTag(output);}privatevoidFirstPage_Click(objectsender,EventArgse){EventArgse1=newEventArgs();if(this.FirstPageOnClick!=null){this.FirstPageOnClick(this.lbFirstPage,e1);}}privatevoidForePage_Click(objectsender,EventArgse){EventArgse1=newEventArgs();if(this.ForePageOnClick!=null){this.ForePageOnClick(this.lbForePage,e1);}}privatevoidNextPage_Click(objectsender,EventArgse){EventArgse1=newEventArgs();if(this.NextPageOnClick!=null){this.NextPageOnClick(this.lbNextPage,e1);}}privatevoidLastPage_Click(objectsender,EventArgse){EventArgse1=newEventArgs();if(this.LastPageOnClick!=null){this.LastPageOnClick(this.lbLastPage,e1);}}privatevoidGoPage_SelectedIndexChanged(objectsender,EventArgse){EventArgse1=newEventArgs();if(this.GoPageChange!=null){this.GoPageChange(this.ddlGoPage,e1);}}privatevoidPageNavigation(){if(pageCount<=1){lbFirstPage.Enabled=false;lbForePage.Enabled=false;lbNextPage.Enabled=false;lbLastPage.Enabled=false;}else{if(currentPage==1){lbFirstPage.Enabled=false;lbForePage.Enabled=false;lbNextPage.Enabled=true;lbLastPage.Enabled=true;}elseif(currentPage!=pageCount){lbFirstPage.Enabled=true;lbForePage.Enabled=true;lbNextPage.Enabled=true;lbLastPage.Enabled=true;}else{lbFirstPage.Enabled=true;lbForePage.Enabled=true;lbNextPage.Enabled=false;lbLastPage.Enabled=false;}}}}}编译后放到工具箱,拖到aspx页面后,提示创建控件出错,未知的服务器标记。本人QQ:110153109