Using Table control in a custom composite control. Control does not render properly in design time.

Discussion in 'ASP .Net' started by jb_in_marietta@yahoo.com, Jul 1, 2003.

  1. Guest

    All,

    I have written a very simple custom composite control that includes a
    control of type System.Web.UI.WebControls.Table.

    The control renders fine in run time, but for some reason, it does not
    render properly in design time.

    In design time it renders something like this:

    [TestTableControl "TestTableControl1"]


    Could someone please explain why this control does not render in
    design time.
    (complete code is included below)

    Thanks in advance!!!

    --Jonathan

    ------------------------------------------------------------------------------


    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    using System.Collections;


    namespace StyleLibFunctions
    {
    #region TestTableControl

    [ToolboxData("<{0}:TestTableControl
    runat=server></{0}:TestTableControl>")]
    public class TestTableControl: WebControl
    {
    #region Variable Declaration

    private Table _table;
    private TableRow _tr;
    private TableCell _td;

    #endregion Variable Declaration

    #region Overridden Properties
    public override ControlCollection Controls
    {
    get
    {
    EnsureChildControls();
    return base.Controls;
    }
    }
    #endregion Overridden Properties

    #region Overridden Methods
    protected override void CreateChildControls ()
    {
    //clear controls
    Controls.Clear();

    //Create a Table object
    _table = new Table();
    _tr = new TableRow();
    _td = new TableCell();
    _td.Controls.Add(new LiteralControl("Cell Content"));

    _tr.Cells.Add(_td);
    _table.Rows.Add(_tr);

    //add table to control tree
    Controls.Add (_table);

    }
    protected override void Render(HtmlTextWriter writer)
    {
    _table.RenderControl(writer);
    }
    #endregion Overridden Methods
    }
    #endregion
    }
     
    , Jul 1, 2003
    #1
    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. Barry Carr
    Replies:
    4
    Views:
    804
    Barry Carr
    Jan 15, 2004
  2. Replies:
    1
    Views:
    394
    Teemu Keiski
    Jul 2, 2003
  3. Replies:
    1
    Views:
    351
    justncase80
    Sep 27, 2005
  4. Paul Hermans

    tabstrip does not render properly on a windows 2003 server

    Paul Hermans, Mar 3, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    167
    Paul Hermans
    Mar 4, 2004
  5. Justin
    Replies:
    12
    Views:
    565
    Justin
    Jul 8, 2005
Loading...

Share This Page