2 // System.Web.UI.HtmlControls.HtmlTable.cs
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2005 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;
33 namespace System.Web.UI.HtmlControls {
36 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
37 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40 [ParseChildren (true, "Rows", ChildControlType = typeof(Control))]
42 [ParseChildren (true, "Rows")]
44 public class HtmlTable : HtmlContainerControl {
46 private HtmlTableRowCollection _rows;
56 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
57 [WebSysDescription("")]
58 [WebCategory("Layout")]
61 string s = Attributes ["align"];
62 return (s == null) ? String.Empty : s;
66 Attributes.Remove ("align");
68 Attributes ["align"] = value;
73 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
74 [WebSysDescription("")]
75 [WebCategory("Appearance")]
76 public string BgColor {
78 string s = Attributes ["bgcolor"];
79 return (s == null) ? String.Empty : s;
83 Attributes.Remove ("bgcolor");
85 Attributes ["bgcolor"] = value;
90 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
91 [WebSysDescription("")]
92 [WebCategory("Appearance")]
95 string s = Attributes ["border"];
96 return (s == null) ? -1 : Convert.ToInt32 (s);
100 Attributes.Remove ("border");
102 Attributes ["border"] = value.ToString (CultureInfo.InvariantCulture);
107 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
108 [WebSysDescription("")]
109 [WebCategory("Appearance")]
110 public string BorderColor {
112 string s = Attributes ["bordercolor"];
113 return (s == null) ? String.Empty : s;
117 Attributes.Remove ("bordercolor");
119 Attributes ["bordercolor"] = value;
124 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
125 [WebSysDescription("")]
126 [WebCategory("Appearance")]
127 public int CellPadding {
129 string s = Attributes ["cellpadding"];
130 return (s == null) ? -1 : Convert.ToInt32 (s);
134 Attributes.Remove ("cellpadding");
136 Attributes ["cellpadding"] = value.ToString (CultureInfo.InvariantCulture);
141 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
142 [WebSysDescription("")]
143 [WebCategory("Appearance")]
144 public int CellSpacing {
146 string s = Attributes ["cellspacing"];
147 return (s == null) ? -1 : Convert.ToInt32 (s);
151 Attributes.Remove ("cellspacing");
153 Attributes ["cellspacing"] = value.ToString (CultureInfo.InvariantCulture);
158 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
159 [WebSysDescription("")]
160 [WebCategory("Layout")]
161 public string Height {
163 string s = Attributes ["height"];
164 return (s == null) ? String.Empty : s;
168 Attributes.Remove ("height");
170 Attributes ["height"] = value;
174 public override string InnerHtml {
175 get { throw new NotSupportedException (); }
176 set { throw new NotSupportedException (); }
179 public override string InnerText {
180 get { throw new NotSupportedException (); }
181 set { throw new NotSupportedException (); }
185 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
186 public virtual HtmlTableRowCollection Rows {
189 _rows = new HtmlTableRowCollection (this);
195 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
196 [WebSysDescription("")]
197 [WebCategory("Layout")]
198 public string Width {
200 string s = Attributes ["width"];
201 return (s == null) ? String.Empty : s;
205 Attributes.Remove ("width");
207 Attributes ["width"] = value;
212 protected override ControlCollection CreateControlCollection ()
214 return new HtmlTableRowControlCollection (this);
222 override void RenderChildren (HtmlTextWriter writer)
224 if (HasControls ()) {
226 base.RenderChildren (writer);
232 protected override void RenderEndTag (HtmlTextWriter writer)
235 writer.WriteEndTag (TagName);
240 protected class HtmlTableRowControlCollection : ControlCollection {
242 internal HtmlTableRowControlCollection (HtmlTable owner)
247 public override void Add (Control child)
250 throw new NullReferenceException ("null");
251 if (!(child is HtmlTableRow))
252 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
257 public override void AddAt (int index, Control child)
260 throw new NullReferenceException ("null");
261 if (!(child is HtmlTableRow))
262 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
264 base.AddAt (index, child);