2 // System.Web.UI.HtmlControls.HtmlTable.cs
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.ComponentModel;
30 using System.Globalization;
31 using System.Security.Permissions;
32 using System.Web.Util;
34 namespace System.Web.UI.HtmlControls
37 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
38 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40 [ParseChildren (true, "Rows")]
41 public class HtmlTable : HtmlContainerControl
43 HtmlTableRowCollection _rows;
51 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
52 [WebSysDescription("")]
53 [WebCategory("Layout")]
56 string s = Attributes ["align"];
57 return (s == null) ? String.Empty : s;
61 Attributes.Remove ("align");
63 Attributes ["align"] = value;
68 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
69 [WebSysDescription("")]
70 [WebCategory("Appearance")]
71 public string BgColor {
73 string s = Attributes ["bgcolor"];
74 return (s == null) ? String.Empty : s;
78 Attributes.Remove ("bgcolor");
80 Attributes ["bgcolor"] = value;
85 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
86 [WebSysDescription("")]
87 [WebCategory("Appearance")]
90 string s = Attributes ["border"];
91 return (s == null) ? -1 : Convert.ToInt32 (s);
95 Attributes.Remove ("border");
97 Attributes ["border"] = value.ToString (Helpers.InvariantCulture);
102 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
103 [WebSysDescription("")]
104 [WebCategory("Appearance")]
105 public string BorderColor {
107 string s = Attributes ["bordercolor"];
108 return (s == null) ? String.Empty : s;
112 Attributes.Remove ("bordercolor");
114 Attributes ["bordercolor"] = value;
119 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
120 [WebSysDescription("")]
121 [WebCategory("Appearance")]
122 public int CellPadding {
124 string s = Attributes ["cellpadding"];
125 return (s == null) ? -1 : Convert.ToInt32 (s);
129 Attributes.Remove ("cellpadding");
131 Attributes ["cellpadding"] = value.ToString (Helpers.InvariantCulture);
136 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
137 [WebSysDescription("")]
138 [WebCategory("Appearance")]
139 public int CellSpacing {
141 string s = Attributes ["cellspacing"];
142 return (s == null) ? -1 : Convert.ToInt32 (s);
146 Attributes.Remove ("cellspacing");
148 Attributes ["cellspacing"] = value.ToString (Helpers.InvariantCulture);
153 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
154 [WebSysDescription("")]
155 [WebCategory("Layout")]
156 public string Height {
158 string s = Attributes ["height"];
159 return (s == null) ? String.Empty : s;
163 Attributes.Remove ("height");
165 Attributes ["height"] = value;
169 public override string InnerHtml {
170 get { throw new NotSupportedException (); }
171 set { throw new NotSupportedException (); }
174 public override string InnerText {
175 get { throw new NotSupportedException (); }
176 set { throw new NotSupportedException (); }
180 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
181 public virtual HtmlTableRowCollection Rows {
184 _rows = new HtmlTableRowCollection (this);
190 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
191 [WebSysDescription("")]
192 [WebCategory("Layout")]
193 public string Width {
195 string s = Attributes ["width"];
196 return (s == null) ? String.Empty : s;
200 Attributes.Remove ("width");
202 Attributes ["width"] = value;
207 protected override ControlCollection CreateControlCollection ()
209 return new HtmlTableRowControlCollection (this);
212 protected internal override void RenderChildren (HtmlTextWriter writer)
214 if (HasControls ()) {
216 base.RenderChildren (writer);
222 protected override void RenderEndTag (HtmlTextWriter writer)
225 writer.WriteEndTag (TagName);
230 protected class HtmlTableRowControlCollection : ControlCollection {
232 internal HtmlTableRowControlCollection (HtmlTable owner)
237 public override void Add (Control child)
240 throw new NullReferenceException ("null");
241 if (!(child is HtmlTableRow))
242 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
247 public override void AddAt (int index, Control child)
250 throw new NullReferenceException ("null");
251 if (!(child is HtmlTableRow))
252 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
254 base.AddAt (index, child);