Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ParseChildren(false) not adding sub objects in the designer

Reply
Thread Tools

ParseChildren(false) not adding sub objects in the designer

 
 
Sam Fields
Guest
Posts: n/a
 
      01-28-2004
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. If the content is literal only, it will add the parsed sub
object "LiteralContent", but if I add any other controls it does not
display.

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>





 
Reply With Quote
 
 
 
 
RadekP
Guest
Posts: n/a
 
      01-28-2004
Sam..

I'm afraid you are never going to achieve design time rendering of children
controls persisted with [ParseChildren(false)] [PersistChildren(true)].
First of - AddParsedSubObject method runs only at run-time. ControlBuilder's
are the ones executed at parse time - they generate a tree similar to
control tree but containing instances of ControlBuilders. Nevertheless I
would recommend to implement ITemplate interface and
TemplatedControlDesigner for control.

Regards

Radek

"Sam Fields" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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. If the content is literal only, it will add the parsed sub
> object "LiteralContent", but if I add any other controls it does not
> display.
>
> 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>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Sharepoint Designer/ Expression Web Designer : adding item in toolbox ? Steve B. ASP .Net 4 06-01-2007 04:29 AM
ParseChildren(false) not adding sub objects in the designer Sam Fields ASP .Net Building Controls 3 01-29-2004 12:47 PM



Advertisments