473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ParseChildren(false) not adding sub objects in the designer

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>

Nov 18 '05 #1
1 2092
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" <sf*****@state.pa.us> wrote in message
news:Ob*************@TK2MSFTNGP12.phx.gbl...
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>


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sundown | last post by:
I am trying to create a custom button control for the web that, when clicked, disables and changes the text of itself and a bunch of other controls (in the collection). My goal is to end up with a...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
4
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a...
0
by: Emil Stoev | last post by:
Howdy eXperts! I have this problem w/ my ASP.NET control. The control is a menu with the following structure: Menu Group 1 Item 1 Item 2 Item 3
3
by: 00_CuMPe3WaR3D12 | last post by:
How do I write a user control that takes HTML and then renders it? Is it possible? I want to do something like this.. <Name:Box id="mybox" runat="server"> <table> .... any html can inserted...
3
by: Chris Newby | last post by:
I have a very simple custom control that derives from WebControls.Panel and implements INamingContainer. It appear that controls created as children of my custom control are having ViewState...
0
by: Umut Tezduyar | last post by:
I have build a sample control but the designer doesn't communicate with it to parse the childen property. Please if you are an control developer, spend your 10 minutes to solve my problem. I have...
0
by: Umut Tezduyar | last post by:
I have build a sample control but the designer doesn't communicate it to parse the childen. Please if you are an control developer, spend your 10 minutes to solve my problem. The main problem...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.