1 // 2 // System.Web.UI.HtmlControls.HtmlTableRow.cs 3 // 4 // Author: 5 // Sebastien Pouliot <sebastien@ximian.com> 6 // 7 // Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com) 8 // 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: 16 // 17 // The above copyright notice and this permission notice shall be 18 // included in all copies or substantial portions of the Software. 19 // 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. 27 // 28 29 using System.ComponentModel; 30 using System.Security.Permissions; 31 32 namespace System.Web.UI.HtmlControls 33 { 34 // CAS 35 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] 36 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] 37 // attributes 38 [ParseChildren (true, "Cells")] 39 public class HtmlTableRow : HtmlContainerControl 40 { 41 HtmlTableCellCollection _cells; 42 HtmlTableRow()43 public HtmlTableRow () 44 : base ("tr") 45 { 46 } 47 48 [DefaultValue ("")] 49 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 50 [WebSysDescription("")] 51 [WebCategory("Layout")] 52 public string Align { 53 get { 54 string s = Attributes ["align"]; 55 return (s == null) ? String.Empty : s; 56 } 57 set { 58 if (value == null) 59 Attributes.Remove ("align"); 60 else 61 Attributes ["align"] = value; 62 } 63 } 64 65 [DefaultValue ("")] 66 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 67 [WebSysDescription("")] 68 [WebCategory("Appearance")] 69 public string BgColor { 70 get { 71 string s = Attributes ["bgcolor"]; 72 return (s == null) ? String.Empty : s; 73 } 74 set { 75 if (value == null) 76 Attributes.Remove ("bgcolor"); 77 else 78 Attributes ["bgcolor"] = value; 79 } 80 } 81 82 [DefaultValue ("")] 83 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 84 [WebSysDescription("")] 85 [WebCategory("Appearance")] 86 public string BorderColor { 87 get { 88 string s = Attributes ["bordercolor"]; 89 return (s == null) ? String.Empty : s; 90 } 91 set { 92 if (value == null) 93 Attributes.Remove ("bordercolor"); 94 else 95 Attributes ["bordercolor"] = value; 96 } 97 } 98 99 [Browsable (false)] 100 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 101 public virtual HtmlTableCellCollection Cells { 102 get { 103 if (_cells == null) 104 _cells = new HtmlTableCellCollection (this); 105 return _cells; 106 } 107 } 108 109 [DefaultValue ("")] 110 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 111 [WebSysDescription("")] 112 [WebCategory("Layout")] 113 public string Height { 114 get { 115 string s = Attributes ["height"]; 116 return (s == null) ? String.Empty : s; 117 } 118 set { 119 if (value == null) 120 Attributes.Remove ("height"); 121 else 122 Attributes ["height"] = value; 123 } 124 } 125 126 public override string InnerHtml { 127 get { throw new NotSupportedException (); } 128 set { throw new NotSupportedException (); } 129 } 130 131 public override string InnerText { 132 get { throw new NotSupportedException (); } 133 set { throw new NotSupportedException (); } 134 } 135 136 [DefaultValue ("")] 137 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 138 [WebSysDescription("")] 139 [WebCategory("Layout")] 140 public string VAlign { 141 get { 142 string s = Attributes ["valign"]; 143 return (s == null) ? String.Empty : s; 144 } 145 set { 146 if (value == null) 147 Attributes.Remove ("valign"); 148 else 149 Attributes ["valign"] = value; 150 } 151 } 152 153 int Count { 154 get { return (_cells == null) ? 0 : _cells.Count; } 155 } 156 157 CreateControlCollection()158 protected override ControlCollection CreateControlCollection () 159 { 160 return new HtmlTableCellControlCollection (this); 161 } 162 RenderChildren(HtmlTextWriter writer)163 protected internal override void RenderChildren (HtmlTextWriter writer) 164 { 165 if (HasControls ()) { 166 writer.Indent++; 167 base.RenderChildren (writer); 168 writer.Indent--; 169 writer.WriteLine (); 170 } 171 } 172 RenderEndTag(HtmlTextWriter writer)173 protected override void RenderEndTag (HtmlTextWriter writer) 174 { 175 if (Count == 0) 176 writer.WriteLine (); 177 writer.WriteEndTag (TagName); 178 if (writer.Indent == 0) 179 writer.WriteLine (); 180 } 181 182 183 protected class HtmlTableCellControlCollection : ControlCollection { 184 HtmlTableCellControlCollection(HtmlTableRow owner)185 internal HtmlTableCellControlCollection (HtmlTableRow owner) 186 : base (owner) 187 { 188 } 189 Add(Control child)190 public override void Add (Control child) 191 { 192 if (child == null) 193 throw new NullReferenceException ("null"); 194 if (!(child is HtmlTableCell)) 195 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableCell instance.")); 196 197 base.Add (child); 198 } 199 AddAt(int index, Control child)200 public override void AddAt (int index, Control child) 201 { 202 if (child == null) 203 throw new NullReferenceException ("null"); 204 if (!(child is HtmlTableCell)) 205 throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableCell instance.")); 206 207 base.AddAt (index, child); 208 } 209 } 210 } 211 } 212