问题描述
自定控件类publicclassAllBookCategoryDropDrownList:DropDownList{publicAllBookCategoryDropDrownList(){this.Items.Add(newListItem("一级分类","0"));foreach(CategoryInfocatinnewCategoryBLL().GetCategoryByID(CategoryType.Book,0)){this.Items.Add(newListItem(cat.CategoryName,cat.CategoryID.ToString()));cat.Cat=newCategoryBLL().GetCategoryByID(CategoryType.ParesentBook,cat.CategoryID);RecursiveAddCat(0,cat.Cat);}}privatevoidRecursiveAddCat(intdepth,IList<CategoryInfo>cats){foreach(CategoryInfocatincats){//Weonlygo3deep//cat.Cat=newCategoryBLL().GetCategoryByID(CategoryType.ParesentBook,cat.CategoryID);switch(depth){case0:this.Items.Add(newListItem("─»"+cat.CategoryName,cat.CategoryID.ToString()));if(cats.Count>0)RecursiveAddCat((depth+1),cat.Cat);break;case1:this.Items.Add(newListItem("└─»"+cat.CategoryName,cat.CategoryID.ToString()));if(cats.Count>0)RecursiveAddCat((depth+1),cat.Cat);break;case2:this.Items.Add(newListItem("└───»"+cat.CategoryName,cat.CategoryID.ToString()));if(cats.Count>0)RecursiveAddCat((depth+1),cat.Cat);break;default:return;}}}}
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="BookCategory.aspx.cs"Inherits="Admin_BookCategory"%><%@RegisterTagPrefix="Category"Namespace="DC_BookShop.Control"Assembly="Control"%><%@RegisterTagPrefix="self"Namespace="DC_BookShop.Common"Assembly="Common"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>图书分类管理</title></head><body><formid="form1"runat="server"><div><asp:TreeViewID="TreeView1"runat="server"></asp:TreeView></div><asp:DropDownListID="DropDownList1"runat="server"></asp:DropDownList> <self:DefaultControlID="DefaultControl1"runat="server"/><Category:AllBookCategoryDropDrownListID="AllBookCategoryDropDrownList1"runat="server"></Category:AllBookCategoryDropDrownList></form></body></html>
运行的时候没问题能显示出来,就是切到设计界面的时候老提示创建服务控件错误
解决方案
解决方案二:
平时没用过自定义控件是不是再创建控件的时候少那些属性请高手指点谢谢
解决方案三:
把鼠标移到该控件上,看看错误提示是什么?