Last post Oct 12, 2007 06:31 PM by viscious
Oct 10, 2007 01:17 AM|Johnson2007|LINK
I want to develop a custom control just like a panel control that can let user drag other controls into it at design time with VS 2005. I want to also add a title ect. to my this custom control. I don't know how to get start. I have seen a article from
Title Joseph at
http://www.codeproject.com/aspnet/panelcurvecontainer.asp. But this is developed in ASP.NET 1.0. But I want to implement it in 2.0. Do you have some good suggestion or any good example? Thank you very much!
Oct 10, 2007 04:07 AM|Johnson2007|LINK
I have tried to implement a simple control as below, but it does not support design mode. In design mode I cannot see the header table. I am not sure why. Or have I made mistake at the very beginning.
public class Main : Panel
private void CreateTable()
t = new Table();
t.ID = "_thePanel";
t.CellPadding = 0;
t.CellSpacing = 0;
t.Width = Unit.Percentage(100); //Width;
t.HorizontalAlign = HorizontalAlign.Center;
t.Style.Add("margin", "0 0 0 0px");
t.BackColor = Color.Blue;
TableRow rowTop = new TableRow();
TableCell leftCell = new TableCell();
leftCell.HorizontalAlign = HorizontalAlign.Left;
leftCell.Style.Add("background", "#99CCFF" + " url(" + "" + "topleft.gif) top left no-repeat");
leftCell.Text = "Test";
protected override void RenderContents(HtmlTextWriter writer)
Oct 12, 2007 06:31 PM|viscious|LINK
Render and its associated methods, are not to be used for manipulating controls, creating controls, or adding controls. Its way to late at this point.
1. Overide CreateChildControls().
2. Call CreateTable() in CreateChildControls().
2. In CreateTable() add the table to the controls collection. IE: Controls.Add(t);
I don't know if thats why your designer is messed up, but if you dont do it like that, it will cause other problems.