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 HtmlTableRowCollection _rows;
50 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
51 [WebSysDescription("")]
52 [WebCategory("Layout")]
55 string s = Attributes ["align"];
56 return (s == null) ? String.Empty : s;
60 Attributes.Remove ("align");
62 Attributes ["align"] = value;
67 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
68 [WebSysDescription("")]
69 [WebCategory("Appearance")]
70 public string BgColor {
72 string s = Attributes ["bgcolor"];
73 return (s == null) ? String.Empty : s;
77 Attributes.Remove ("bgcolor");
79 Attributes ["bgcolor"] = value;
84 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
85 [WebSysDescription("")]
86 [WebCategory("Appearance")]
89 string s = Attributes ["border"];
90 return (s == null) ? -1 : Convert.ToInt32 (s);
94 Attributes.Remove ("border");
96 Attributes ["border"] = value.ToString (CultureInfo.InvariantCulture);
101 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
102 [WebSysDescription("")]
103 [WebCategory("Appearance")]
104 public string BorderColor {
106 string s = Attributes ["bordercolor"];
107 return (s == null) ? String.Empty : s;
111 Attributes.Remove ("bordercolor");
113 Attributes ["bordercolor"] = value;
118 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
119 [WebSysDescription("")]
120 [WebCategory("Appearance")]
121 public int CellPadding {
123 string s = Attributes ["cellpadding"];
124 return (s == null) ? -1 : Convert.ToInt32 (s);
128 Attributes.Remove ("cellpadding");
130 Attributes ["cellpadding"] = value.ToString (CultureInfo.InvariantCulture);
135 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
136 [WebSysDescription("")]
137 [WebCategory("Appearance")]
138 public int CellSpacing {
140 string s = Attributes ["cellspacing"];
141 return (s == null) ? -1 : Convert.ToInt32 (s);
145 Attributes.Remove ("cellspacing");
147 Attributes ["cellspacing"] = value.ToString (CultureInfo.InvariantCulture);
152 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
153 [WebSysDescription("")]
154 [WebCategory("Layout")]
155 public string Height {
157 string s = Attributes ["height"];
158 return (s == null) ? String.Empty : s;
162 Attributes.Remove ("height");
164 Attributes ["height"] = value;
168 public override string InnerHtml {
169 get { throw new NotSupportedException (); }
170 set { throw new NotSupportedException (); }
173 public override string InnerText {
174 get { throw new NotSupportedException (); }
175 set { throw new NotSupportedException (); }
179 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
180 public virtual HtmlTableRowCollection Rows {
183 _rows = new HtmlTableRowCollection (this);
189 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
190 [WebSysDescription("")]
191 [WebCategory("Layout")]
192 public string Width {
194 string s = Attributes ["width"];
195 return (s == null) ? String.Empty : s;
199 Attributes.Remove ("width");
201 Attributes ["width"] = value;
206 protected override ControlCollection CreateControlCollection ()
208 return new HtmlTableRowControlCollection (this);
216 override void RenderChildren (HtmlTextWriter writer)
218 if (HasControls ()) {
220 base.RenderChildren (writer);
226 protected override void RenderEndTag (HtmlTextWriter writer)
229 writer.WriteEndTag (TagName);
234 protected class HtmlTableRowControlCollection : ControlCollection {
236 internal HtmlTableRowControlCollection (HtmlTable owner)
241 public override void Add (Control child)
244 throw new NullReferenceException ("null");
245 if (!(child is HtmlTableRow))
246 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
251 public override void AddAt (int index, Control child)
254 throw new NullReferenceException ("null");
255 if (!(child is HtmlTableRow))
256 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableRow instance."));
258 base.AddAt (index, child);