1 /* System.Web.UI.HtmlControls
3 * Leen Toelen (toelen@hotmail.com)
7 using System
.ComponentModel
;
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
){
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
);
37 [WebCategory("Layout")]
38 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
41 string attr
= Attributes
["align"];
42 if (attr
!= null) return attr
;
46 Attributes
["align"] = AttributeToString(value);
51 [WebCategory("Appearance")]
52 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
53 public string BgColor
{
55 string attr
= Attributes
["bgcolor"];
56 if (attr
!= null) return attr
;
60 Attributes
["bgcolor"] = AttributeToString(value);
65 [WebCategory("Appearance")]
66 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
69 string attr
= Attributes
["border"];
70 if (attr
!= null) return Int32
.Parse(attr
, CultureInfo
.InvariantCulture
);
74 Attributes
["border"] = AttributeToString(value);
79 [WebCategory("Appearance")]
80 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
81 public string BorderColor
{
83 string attr
= Attributes
["bordercolor"];
84 if (attr
!= null) return attr
;
88 Attributes
["bordercolor"] = AttributeToString(value);
93 [WebCategory("Appearance")]
94 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
95 public int CellPadding
{
97 string attr
= Attributes
["cellpadding"];
98 if (attr
!= null) return Int32
.Parse(attr
, CultureInfo
.InvariantCulture
);
102 Attributes
["cellpadding"] = AttributeToString(value);
107 [WebCategory("Appearance")]
108 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
109 public int CellSpacing
{
111 string attr
= Attributes
["cellspacing"];
112 if (attr
!= null) return Int32
.Parse(attr
, CultureInfo
.InvariantCulture
);
116 Attributes
["cellspacing"] = AttributeToString(value);
121 [WebCategory("Layout")]
122 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
123 public string Height
{
125 string attr
= Attributes
["height"];
126 if (attr
!= null) return attr
;
130 Attributes
["height"] = AttributeToString(value);
134 public override string InnerHtml
{
136 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
139 throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
143 public override string InnerText
{
145 throw new NotSupportedException("InnerText property not supported by HtmlTable");
148 throw new NotSupportedException("InnerText property not supported by HtmlTable");
152 [IgnoreUnknownContent ()]
154 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
155 public virtual HtmlTableRowCollection Rows
{
157 if (_rows
== null) _rows
= new HtmlTableRowCollection(this);
163 [WebCategory("Layout")]
164 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
165 public string Width
{
167 string attr
= Attributes
["width"];
168 if (attr
!= null) return attr
;
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){
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
);
194 throw new ArgumentException("HtmlTableRow cannot have children of type " + child
.GetType().Name
);
197 } // end of HtmlTableRowControlCollection
199 // end of System.Web.UI.HtmlControl