lovetocook
New Member
Hello Everybody I wantodevelop a custom control that inherits from webcontrol class.my custom control contains panels that include two butons(first copyclipboard second delete) and one image.when click first button,copy image link to clipboard and when click second button , panel will delete from mycontrol control collection.mycontrol have a property that named imageLinks , typed list.panels dynamicly added in my control when in default.aspx button that named addnew click. I read custom control development documantation from micrsofot site.I learn add events overriding init or preinit method.I want to add panels to mycontrol using imagelinks property.therefore overringin init method can't add panel because firstly throw init event and anything can't add. \[code\]//in default.aspx button clickprotected void btn_Click(object sender,eventargs e){string url="www.domain.com/images/a.jpg";mycontrol.imageLinks.add(url);}//in mycustom controlpublic override void CreateChilControl(){ base.CreateChildControls(); this.Controls.Clear(); foreach (String co in imageList) { Panel p = new Panel(); .... Button b = new Button(); b.Height = b.Width = 60; b.Text ="btn_"+guid.NewGuid().Tostring().Substring(0,3) b.Click += new EventHandler(l_Click); .... p.Control.add(b); this.Controls.Add(p); }//foreach ChildControlsCreated = true;}//viewstate protected override void LoadViewState(object savedState) { Pair p =((Pair)savedState); base.LoadViewState(p.First); imageLinks= p.Second as List<string>; }//func protected override object SaveViewState() { Pair p = new Pair(); p.First = base.SaveViewState(); p.Second = imageLinks; return p; }//func//render protected override void RenderContents( HtmlTextWriter writer) { writer.RenderBeginTag(HtmlTextWriterTag.Table); foreach (Control item in Controls) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); item.RenderControl(writer); }//foreach writer.RenderEndTag(); }\[/code\]uccedfully add controls but can't throw click event;where I add Controls which override method where add event to controls