S
Sam Fields
I have been wrestling with this code for about 2 weeks now. My goal is to
create a table for formatting purposes. I want to standardize it as a
webcontrol. I want all of the content to persist as top-level controls so
that they are visible to the asp.net designer -- PersistChildren(true). The
code works fine for run-time, but will not call AddParsedSubObject for
design-time. How do I get my child controls to display properly in the
asp.net designer?
Thanks to any who can help!
Sam Fields
Here is a sample of what I am trying to build in its simplest format:
c# code:
namespace testbed
{
[ParseChildren(false), PersistChildren(true)]
[ToolboxData("<{0}:test runat=server></{0}:test>")]
public class test : Table
{
private TableCell innercell = new TableCell();
public test()
{
this.Rows.Add(new TableRow());
this.Rows[0].Cells.Add(new TableCell());
this.Rows[0].Cells[0].Text = "Header";
this.Rows.Add(new TableRow());
this.Rows[1].Cells.Add(innercell);
this.Rows.Add(new TableRow());
this.Rows[2].Cells.Add(new TableCell());
this.Rows[2].Cells[0].Text = "Footer";
}
protected override void AddParsedSubObject(object obj)
{
innercell.Controls.Add((Control) obj);
this.ChildControlsCreated = false;
}
}
}
..aspx page:
<%@ Register TagPrefix="cc" Namespace="testbed" Assembly="testbed" %>
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false"
Inherits="testbed._default" %>
<HTML>
<HEAD>
<title>default</title>
</HEAD>
<body>
<form id="default" method="post" runat="server">
<cc:test id="content" runat="server">
MyContent
<asp:Label id="mylabel" text="MyLabel" Runat="server"></asp:Label>
</cc:test>
</form>
</body>
</HTML>
create a table for formatting purposes. I want to standardize it as a
webcontrol. I want all of the content to persist as top-level controls so
that they are visible to the asp.net designer -- PersistChildren(true). The
code works fine for run-time, but will not call AddParsedSubObject for
design-time. How do I get my child controls to display properly in the
asp.net designer?
Thanks to any who can help!
Sam Fields
Here is a sample of what I am trying to build in its simplest format:
c# code:
namespace testbed
{
[ParseChildren(false), PersistChildren(true)]
[ToolboxData("<{0}:test runat=server></{0}:test>")]
public class test : Table
{
private TableCell innercell = new TableCell();
public test()
{
this.Rows.Add(new TableRow());
this.Rows[0].Cells.Add(new TableCell());
this.Rows[0].Cells[0].Text = "Header";
this.Rows.Add(new TableRow());
this.Rows[1].Cells.Add(innercell);
this.Rows.Add(new TableRow());
this.Rows[2].Cells.Add(new TableCell());
this.Rows[2].Cells[0].Text = "Footer";
}
protected override void AddParsedSubObject(object obj)
{
innercell.Controls.Add((Control) obj);
this.ChildControlsCreated = false;
}
}
}
..aspx page:
<%@ Register TagPrefix="cc" Namespace="testbed" Assembly="testbed" %>
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false"
Inherits="testbed._default" %>
<HTML>
<HEAD>
<title>default</title>
</HEAD>
<body>
<form id="default" method="post" runat="server">
<cc:test id="content" runat="server">
MyContent
<asp:Label id="mylabel" text="MyLabel" Runat="server"></asp:Label>
</cc:test>
</form>
</body>
</HTML>