J
johnny
I have been unable to get some of my custom server controls that have
children to render properly in the vs.net designer. I have gone
through other postings and tried their suggestions, but nothing has
worked. Below are a couple of simple controls I came up with to
illustrate my problem. Hopefully, someone can help me out.
[ParseChildren(false), PersistChildren(true)]
public class ChildControl : Control, INamingContainer
{
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<tr><td>Hello");
base.Render (writer);
writer.Write("</td></tr>");
}
}
[ParseChildren(false), PersistChildren(true)]
public class ParentControl : Control, INamingContainer
{
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<table>");
base.Render (writer);
writer.Write("</table>");
}
Then in the aspx file:
<form id="Form1" method="post" runat="server">
<Custom
arentControl id="p" runat="server">
<Custom:ChildControl id="c1" runat="server" />
<Custom:ChildControl id="c2" runat="server" />
</Custom
arentControl>
</form>
Thanks
children to render properly in the vs.net designer. I have gone
through other postings and tried their suggestions, but nothing has
worked. Below are a couple of simple controls I came up with to
illustrate my problem. Hopefully, someone can help me out.
[ParseChildren(false), PersistChildren(true)]
public class ChildControl : Control, INamingContainer
{
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<tr><td>Hello");
base.Render (writer);
writer.Write("</td></tr>");
}
}
[ParseChildren(false), PersistChildren(true)]
public class ParentControl : Control, INamingContainer
{
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<table>");
base.Render (writer);
writer.Write("</table>");
}
Then in the aspx file:
<form id="Form1" method="post" runat="server">
<Custom
<Custom:ChildControl id="c1" runat="server" />
<Custom:ChildControl id="c2" runat="server" />
</Custom
</form>
Thanks