Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / January 2004

Tip: Looking for answers? Try searching our database.

ParseChildren(false) not adding sub objects in the designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sam Fields - 28 Jan 2004 17:25 GMT
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
Sam Fields - 28 Jan 2004 19:03 GMT
More information:
If the inner content is literal, the AddParsedSubObject override is adding
the "LiteralControl" at design time.  It is only when the <asp:Label> is
added to the inner content that the design time rendering fails.

Any help would be greatly appreciated!
Thanks, 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
[quoted text clipped - 56 lines]
>  </body>
> </HTML
RadekP - 28 Jan 2004 22:37 GMT
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

> More information:
> If the inner content is literal, the AddParsedSubObject override is adding
[quoted text clipped - 66 lines]
> >  </body>
> > </HTML
Sam Fields - 29 Jan 2004 12:47 GMT
I will give that a try.  It doesn't make sense, though, that a
LiteralControl is added to the inner cell at design time if the literal is
the only contained information.  Why, then, does this happen if
AddParsedSubObject is a run-time only call?

Thanks for your response!  Sam

> Sam..
>
[quoted text clipped - 82 lines]
> > >  </body>
> > > </HTML

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.