1 /* System.Web.UI.HtmlControls
3 * Leen Toelen (toelen@hotmail.com)
10 namespace System.Web.UI.HtmlControls{
12 public class HtmlTable : HtmlContainerControl {
13 private HtmlTableRowCollection _rows;
15 public HtmlTable():base("table");
17 protected override ControlCollection CreateControlCollection(){
18 return new HtmlTableRowControlCollection;
21 protected override void RenderChildren(HtmlTextWriter writer){
23 writer.Indent = writer.Indent + 1;
25 writer.Indent = writer.Indent - 1;
28 protected override void RenderEndTag(HtmlTextWriter writer){
29 base.RenderEndTag(writer);
35 string attr = Attributes["align"];
36 if (attr != null) return attr;
40 Attributes["align"] = MapStringAttributeToString(value);
44 public string BgColor {
46 string attr = Attributes["bgcolor"];
47 if (attr != null) return attr;
51 Attributes["bgcolor"] = MapStringAttributeToString(value);
57 string attr = Attributes["border"];
58 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
62 Attributes["border"] = MapIntegerAttributeToString(value);
66 public string BorderColor {
68 string attr = Attributes["bordercolor"];
69 if (attr != null) return attr;
73 Attributes["bordercolor"] = MapStringAttributeToString(value);
77 public int CellPadding {
79 string attr = Attributes["cellpadding"];
80 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
84 Attributes["cellpadding"] = MapIntegerAttributeToString(value);
88 public int CellSpacing {
90 string attr = Attributes["cellspacing"];
91 if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture);
95 Attributes["cellspacing"] = MapIntegerAttributeToString(value);
99 public string Height {
101 string attr = Attributes["height"];
102 if (attr != null) return attr;
106 Attributes["height"] = MapStringAttributeToString(value);
110 public override string InnerHtml {
112 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name);
115 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name);
119 public override string InnerText {
121 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name);
124 throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name);
128 public virtual HtmlTableRowCollection Rows {
130 if (_rows == null) _rows = new HtmlTableRowCollection;
135 public string Height {
137 string attr = Attributes["width"];
138 if (attr != null) return attr;
142 Attributes["width"] = MapStringAttributeToString(value);
145 private protected class HtmlTableRowControlCollection : ControlCollection {
146 internal HtmlTableCellControlCollection(Control owner): base(owner);
148 public override void Add(Control child){
149 if (child Is HtmlTableCell){
153 throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString);
157 public override void AddAt(int index, Control child){
158 if (child Is HtmlTableCell){
159 base.AddAt(index,child);
162 throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString);
165 } // end of HtmlTableRowControlCollection
167 // end of System.Web.UI.HtmlControl