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)]
39 [ParseChildren (true, "Rows")]
40 public class HtmlTable : HtmlContainerControl {
42 private HtmlTableRowCollection _rows;
52 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
53 [WebSysDescription("")]
54 [WebCategory("Layout")]
57 string s = Attributes ["align"];
58 return (s == null) ? String.Empty : s;
62 Attributes.Remove ("align");
64 Attributes ["align"] = value;
69 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
70 [WebSysDescription("")]
71 [WebCategory("Appearance")]
72 public string BgColor {
74 string s = Attributes ["bgcolor"];
75 return (s == null) ? String.Empty : s;
79 Attributes.Remove ("bgcolor");
81 Attributes ["bgcolor"] = value;
86 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
87 [WebSysDescription("")]
88 [WebCategory("Appearance")]
91 string s = Attributes ["border"];
92 return (s == null) ? -1 : Convert.ToInt32 (s);
96 Attributes.Remove ("border");
98 Attributes ["border"] = value.ToString (CultureInfo.InvariantCulture);
103 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
104 [WebSysDescription("")]
105 [WebCategory("Appearance")]
106 public string BorderColor {
108 string s = Attributes ["bordercolor"];
109 return (s == null) ? String.Empty : s;
113 Attributes.Remove ("bordercolor");
115 Attributes ["bordercolor"] = value;
120 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
121 [WebSysDescription("")]
122 [WebCategory("Appearance")]
123 public int CellPadding {
125 string s = Attributes ["cellpadding"];
126 return (s == null) ? -1 : Convert.ToInt32 (s);
130 Attributes.Remove ("cellpadding");
132 Attributes ["cellpadding"] = value.ToString (CultureInfo.InvariantCulture);
137 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
138 [WebSysDescription("")]
139 [WebCategory("Appearance")]
140 public int CellSpacing {
142 string s = Attributes ["cellspacing"];
143 return (s == null) ? -1 : Convert.ToInt32 (s);
147 Attributes.Remove ("cellspacing");
149 Attributes ["cellspacing"] = value.ToString (CultureInfo.InvariantCulture);
154 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
155 [WebSysDescription("")]
156 [WebCategory("Layout")]
157 public string Height {
159 string s = Attributes ["height"];
160 return (s == null) ? String.Empty : s;
164 Attributes.Remove ("height");
166 Attributes ["height"] = value;
170 public override string InnerHtml {
171 get { throw new NotSupportedException (); }
172 set { throw new NotSupportedException (); }
175 public override string InnerText {
176 get { throw new NotSupportedException (); }
177 set { throw new NotSupportedException (); }
181 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
182 public virtual HtmlTableRowCollection Rows {
185 _rows = new HtmlTableRowCollection (this);
191 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
192 [WebSysDescription("")]
193 [WebCategory("Layout")]
194 public string Width {
196 string s = Attributes ["width"];
197 return (s == null) ? String.Empty : s;
201 Attributes.Remove ("width");
203 Attributes ["width"] = value;
208 protected override ControlCollection CreateControlCollection ()
210 return new HtmlTableRowControlCollection (this);
218 override void RenderChildren (HtmlTextWriter writer)
220 if (HasControls ()) {
222 base.RenderChildren (writer);
228 protected override void RenderEndTag (HtmlTextWriter writer)
231 writer.WriteEndTag (TagName);
236 protected class HtmlTableRowControlCollection : ControlCollection {
238 internal HtmlTableRowControlCollection (HtmlTable owner)
243 public override void Add (Control child)
246 throw new NullReferenceException ("null");
247 if (!(child is HtmlTableRow))
248 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
253 public override void AddAt (int index, Control child)
256 throw new NullReferenceException ("null");
257 if (!(child is HtmlTableRow))
258 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
260 base.AddAt (index, child);