Groups | Blog | Home
all groups > asp.net building controls > july 2004 >

asp.net building controls : Control Removing contents when editing properties


MattC
7/14/2004 3:10:25 PM
I have a custom control, that I add via the HTML view of my aspx page. I
then also manually added a datagrid as a child control.

<mycontrol:tagname runat=server id=foo>
<asp:datagrid runat=server id=foobar></asp:datagrid>
</mycontrol:tagname>

When I switch to design mode and edit the control foo's properties and then
switch back to html view the datagrid is gone.

Also the dataggrid does not show up in design view.

Here is my controls render section:

protected override void RenderChildren(HtmlTextWriter writer)
{
WritePanelTop(writer); //writes out table beginning
base.RenderChildren(writer); //should write out the datagrid via its
render method
WritePanelBottom(writer); //writes out tables end
}

Help?!?!

MattC

John Saunders
7/15/2004 1:30:32 PM
[quoted text, click to view]

Matt, how do you have ParseChildren set for your control? Also, have you
considered deriving from the Panel control, which already knows how to
contain child controls?
--
John Saunders
johnwsaundersiii at hotmail

MattC
7/16/2004 9:27:21 AM
John,

I have ParseChildren(false) and I am deriving from Panel.

I also havea problem with the controls inside not maintaining their state.

protected override void Render(HtmlTextWriter writer)
{
WritePanelTop(writer);

if(!Page.IsPostBack && (_defaultHide == true) || (Page.IsPostBack &&
_hide == true))
{
SwitchImage();

foreach(Control c in this.Controls)
{
c.Visible = false;
}

}

base.RenderChildren(writer);

WritePanelBottom(writer);

}

MattC


[quoted text, click to view]

AddThis Social Bookmark Button