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