**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlTable.cs
blob79750d5efe8e5cd8d7618ec7396d5dfecaf3a275
1 /* System.Web.UI.HtmlControls
2 * Authors
3 * Leen Toelen (toelen@hotmail.com)
4 */
6 using System;
7 using System.ComponentModel;
8 using System.Web;
9 using System.Web.UI;
10 using System.Globalization;
12 namespace System.Web.UI.HtmlControls{
14 [ParseChildren(true, "Rows")]
15 public class HtmlTable : HtmlContainerControl {
16 private HtmlTableRowCollection _rows;
18 public HtmlTable():base("table"){}
20 protected override ControlCollection CreateControlCollection(){
21 return new HtmlTableRowControlCollection(this);
24 protected override void RenderChildren(HtmlTextWriter writer){
25 writer.WriteLine();
26 writer.Indent = writer.Indent + 1;
27 base.RenderChildren(writer);
28 writer.Indent = writer.Indent - 1;
31 protected override void RenderEndTag(HtmlTextWriter writer){
32 base.RenderEndTag(writer);
33 writer.WriteLine();
36 [DefaultValue("")]
37 [WebCategory("Layout")]
38 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
39 public string Align {
40 get{
41 string attr = Attributes["align"];
42 if (attr != null) return attr;
43 return String.Empty;
45 set{
46 Attributes["align"] = AttributeToString(value);
50 [DefaultValue("")]
51 [WebCategory("Appearance")]
52 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
53 public string BgColor {
54 get{
55 string attr = Attributes["bgcolor"];
56 if (attr != null) return attr;
57 return String.Empty;
59 set{
60 Attributes["bgcolor"] = AttributeToString(value);
64 [DefaultValue(-1)]
65 [WebCategory("Appearance")]
66 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
67 public int Border {
68 get{
69 string attr = Attributes["border"];
70 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
71 return -1;
73 set{
74 Attributes["border"] = AttributeToString(value);
78 [DefaultValue("")]
79 [WebCategory("Appearance")]
80 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
81 public string BorderColor {
82 get{
83 string attr = Attributes["bordercolor"];
84 if (attr != null) return attr;
85 return String.Empty;
87 set{
88 Attributes["bordercolor"] = AttributeToString(value);
92 [DefaultValue("")]
93 [WebCategory("Appearance")]
94 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
95 public int CellPadding {
96 get{
97 string attr = Attributes["cellpadding"];
98 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
99 return -1;
101 set{
102 Attributes["cellpadding"] = AttributeToString(value);
106 [DefaultValue("")]
107 [WebCategory("Appearance")]
108 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
109 public int CellSpacing {
110 get{
111 string attr = Attributes["cellspacing"];
112 if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
113 return -1;
115 set{
116 Attributes["cellspacing"] = AttributeToString(value);
120 [DefaultValue("")]
121 [WebCategory("Layout")]
122 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
123 public string Height {
124 get{
125 string attr = Attributes["height"];
126 if (attr != null) return attr;
127 return String.Empty;
129 set{
130 Attributes["height"] = AttributeToString(value);
134 public override string InnerHtml {
135 get{
136 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
138 set{
139 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
143 public override string InnerText {
144 get{
145 throw new NotSupportedException("InnerText property not supported by HtmlTable");
147 set{
148 throw new NotSupportedException("InnerText property not supported by HtmlTable");
152 [IgnoreUnknownContent ()]
153 [Browsable(false)]
154 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
155 public virtual HtmlTableRowCollection Rows {
156 get{
157 if (_rows == null) _rows = new HtmlTableRowCollection(this);
158 return _rows;
162 [DefaultValue("")]
163 [WebCategory("Layout")]
164 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
165 public string Width {
166 get{
167 string attr = Attributes["width"];
168 if (attr != null) return attr;
169 return String.Empty;
171 set{
172 Attributes["width"] = AttributeToString(value);
176 protected class HtmlTableRowControlCollection : ControlCollection {
178 internal HtmlTableRowControlCollection(Control owner): base(owner){}
180 public override void Add(Control child){
181 if ((child as HtmlTableRow) != null){
182 base.Add(child);
184 else{
185 throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
189 public override void AddAt(int index, Control child){
190 if ((child as HtmlTableRow) != null){
191 base.AddAt(index,child);
193 else{
194 throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
197 } // end of HtmlTableRowControlCollection
199 // end of System.Web.UI.HtmlControl