Control Removing contents when editing properties

Discussion in 'ASP .Net Building Controls' started by MattC, Jul 14, 2004.

  1. MattC

    MattC Guest

    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
    MattC, Jul 14, 2004
    #1
    1. Advertising

  2. "MattC" <> wrote in message
    news:...
    > 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?
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jul 15, 2004
    #2
    1. Advertising

  3. MattC

    MattC Guest

    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


    "John Saunders" <> wrote in message
    news:#...
    > "MattC" <> wrote in message
    > news:...
    > > 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?
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
    MattC, Jul 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas
    Replies:
    2
    Views:
    3,138
    Jay Douglas
    Nov 2, 2003
  2. Replies:
    0
    Views:
    585
  3. Radu
    Replies:
    0
    Views:
    295
  4. Radu
    Replies:
    2
    Views:
    896
  5. Replies:
    6
    Views:
    137
    Joe Smith
    Jan 16, 2005
Loading...

Share This Page