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




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!!!



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

namespace StyleLibFunctions
#region 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
return base.Controls;
#endregion Overridden Properties

#region Overridden Methods
protected override void CreateChildControls ()
//clear controls

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


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

protected override void Render(HtmlTextWriter writer)
#endregion Overridden Methods

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