1 // 2 // System.Web.UI.WebControls.TableRow.cs 3 // 4 // Author: 5 // Sebastien Pouliot <sebastien@ximian.com> 6 // 7 // Copyright (C) 2005 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.WebControls { 33 34 // CAS 35 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] 36 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] 37 // attributes 38 [DefaultProperty ("Cells")] 39 [ParseChildren (true, "Cells")] 40 [ToolboxItem ("")] 41 [Bindable (false)] 42 [Designer ("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")] 43 public class TableRow : WebControl 44 { 45 TableCellCollection cells; 46 bool tableRowSectionSet; 47 48 internal TableRowCollection Container { get; set; } 49 TableRow()50 public TableRow () 51 : base (HtmlTextWriterTag.Tr) 52 { 53 AutoID = false; 54 } 55 56 internal bool TableRowSectionSet { 57 get { return tableRowSectionSet; } 58 } 59 60 [MergableProperty (false)] 61 [PersistenceMode (PersistenceMode.InnerDefaultProperty)] 62 [WebSysDescription ("")] 63 [WebCategory("Layout")] 64 public virtual TableCellCollection Cells { 65 get { 66 if (cells == null) 67 cells = new TableCellCollection (this); 68 return cells; 69 } 70 } 71 72 [DefaultValue (HorizontalAlign.NotSet)] 73 [WebSysDescription ("")] 74 [WebCategory ("Layout")] 75 public virtual HorizontalAlign HorizontalAlign { 76 get { 77 if (!ControlStyleCreated) 78 return HorizontalAlign.NotSet; // default value 79 return TableItemStyle.HorizontalAlign; 80 } 81 set { TableItemStyle.HorizontalAlign = value; } 82 } 83 84 [DefaultValue (VerticalAlign.NotSet)] 85 [WebSysDescription ("")] 86 [WebCategory ("Layout")] 87 public virtual VerticalAlign VerticalAlign { 88 get { 89 if (!ControlStyleCreated) 90 return VerticalAlign.NotSet; // default value 91 return TableItemStyle.VerticalAlign; 92 } 93 set { TableItemStyle.VerticalAlign = value; } 94 } 95 96 TableItemStyle TableItemStyle { 97 get { return (ControlStyle as TableItemStyle); } 98 } 99 public override bool SupportsDisabledAttribute { 100 get { return RenderingCompatibilityLessThan40; } 101 } CreateControlCollection()102 protected override ControlCollection CreateControlCollection () 103 { 104 return new CellControlCollection (this); 105 } 106 CreateControlStyle()107 protected override Style CreateControlStyle () 108 { 109 return new TableItemStyle (ViewState); 110 } 111 [DefaultValue (TableRowSection.TableBody)] 112 public virtual TableRowSection TableSection { 113 get { 114 object o = ViewState ["TableSection"]; 115 return (o == null) ? TableRowSection.TableBody : (TableRowSection) o; 116 } 117 set { 118 if ((value < TableRowSection.TableHeader) || (value > TableRowSection.TableFooter)) 119 throw new ArgumentOutOfRangeException ("TableSection"); 120 ViewState ["TableSection"] = (int) value; 121 tableRowSectionSet = true; 122 TableRowCollection container = Container; 123 if (container != null) 124 container.RowTableSectionSet (); 125 } 126 } 127 // inner class 128 protected class CellControlCollection : ControlCollection { 129 CellControlCollection(TableRow owner)130 internal CellControlCollection (TableRow owner) 131 : base (owner) 132 { 133 } 134 135 Add(Control child)136 public override void Add (Control child) 137 { 138 if (child == null) 139 throw new NullReferenceException ("null"); 140 if (!(child is TableCell)) 141 throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance.")); 142 143 base.Add (child); 144 } 145 AddAt(int index, Control child)146 public override void AddAt (int index, Control child) 147 { 148 if (child == null) 149 throw new NullReferenceException ("null"); 150 if (!(child is TableCell)) 151 throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance.")); 152 153 base.AddAt (index, child); 154 } 155 } 156 } 157 } 158