Control Removing contents when editing properties

M

MattC

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
 
J

John Saunders

MattC said:
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
}

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?
 
M

MattC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top