/// <include file='doc\TableDesigner.uex' path='docs/doc[@for="TableDesigner.GetDesignTimeHtml"]/*' /> /// <devdoc> /// <para> /// Gets the design time HTML of the <see cref='System.Web.UI.WebControls.Table'/> /// control. /// </para> /// </devdoc> public override string GetDesignTimeHtml() { Table table = (Table)Component; TableRowCollection rows = table.Rows; ArrayList cellsWithDummyContents = null; bool emptyTable = (rows.Count == 0); bool emptyRows = false; if (emptyTable) { TableRow row = new TableRow(); rows.Add(row); TableCell cell = new TableCell(); cell.Text = "###"; rows[0].Cells.Add(cell); } else { emptyRows = true; for (int i = 0; i < rows.Count; i++) { if (rows[i].Cells.Count != 0) { emptyRows = false; break; } } if (emptyRows == true) { TableCell cell = new TableCell(); cell.Text = "###"; rows[0].Cells.Add(cell); } } if (emptyTable == false) { // rows and cells were defined by the user, but if the cells are empty // then something needs to be done about that, so they are visible foreach (TableRow row in rows) { foreach (TableCell cell in row.Cells) { if ((cell.Text.Length == 0) && (cell.HasControls() == false)) { if (cellsWithDummyContents == null) { cellsWithDummyContents = new ArrayList(); } cellsWithDummyContents.Add(cell); cell.Text = "###"; } } } } // now get the design-time HTML string designTimeHTML = base.GetDesignTimeHtml(); // and restore the table back to the way it was if (emptyTable) { // restore the table back to its empty state rows.Clear(); } else { // restore the cells that were empty if (cellsWithDummyContents != null) { foreach (TableCell cell in cellsWithDummyContents) { cell.Text = String.Empty; } } if (emptyRows) { // we added a cell into row 0, so remove it rows[0].Cells.Clear(); } } return(designTimeHTML); }