1 /* System.Web.UI.HtmlControls
3 * Leen Toelen (toelen@hotmail.com)
9 using System.Globalization;
11 namespace System.Web.UI.HtmlControls{
13 public class HtmlTable : HtmlContainerControl {
14 private HtmlTableRowCollection _rows;
16 public HtmlTable():base("table"){}
18 protected override ControlCollection CreateControlCollection(){
19 return new HtmlTableRowControlCollection(this);
22 protected override void RenderChildren(HtmlTextWriter writer){
24 writer.Indent = writer.Indent + 1;
25 base.RenderChildren(writer);
26 writer.Indent = writer.Indent - 1;
29 protected new void RenderEndTag(HtmlTextWriter writer){
30 base.RenderEndTag(writer);
36 string attr = Attributes["align"];
37 if (attr != null) return attr;
41 Attributes["align"] = AttributeToString(value);
45 public string BgColor {
47 string attr = Attributes["bgcolor"];
48 if (attr != null) return attr;
52 Attributes["bgcolor"] = AttributeToString(value);
58 string attr = Attributes["border"];
59 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
63 Attributes["border"] = AttributeToString(value);
67 public string BorderColor {
69 string attr = Attributes["bordercolor"];
70 if (attr != null) return attr;
74 Attributes["bordercolor"] = AttributeToString(value);
78 public int CellPadding {
80 string attr = Attributes["cellpadding"];
81 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
85 Attributes["cellpadding"] = AttributeToString(value);
89 public int CellSpacing {
91 string attr = Attributes["cellspacing"];
92 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
96 Attributes["cellspacing"] = AttributeToString(value);
100 public string Height {
102 string attr = Attributes["height"];
103 if (attr != null) return attr;
107 Attributes["height"] = AttributeToString(value);
111 public override string InnerHtml {
113 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
116 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
120 public override string InnerText {
122 throw new NotSupportedException("InnerText property not supported by HtmlTable");
125 throw new NotSupportedException("InnerText property not supported by HtmlTable");
129 public virtual HtmlTableRowCollection Rows {
131 if (_rows == null) _rows = new HtmlTableRowCollection(this);
136 public string Width {
138 string attr = Attributes["width"];
139 if (attr != null) return attr;
143 Attributes["width"] = AttributeToString(value);
147 protected class HtmlTableRowControlCollection : ControlCollection {
149 internal HtmlTableRowControlCollection(Control owner): base(owner){}
151 public override void Add(Control child){
152 if ((child as HtmlTableCell) != null){
156 throw new ArgumentException("HtmlTableRow cannot have children of type" + child.GetType().Name);
160 public override void AddAt(int index, Control child){
161 if ((child as HtmlTableCell) != null){
162 base.AddAt(index,child);
165 throw new ArgumentException("HtmlTableRow cannot have children of type" + child.GetType().Name);
168 } // end of HtmlTableRowControlCollection
170 // end of System.Web.UI.HtmlControl