2 // System.Web.UI.WebControls.TableRow.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.Security.Permissions;
32 namespace System.Web.UI.WebControls {
35 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
36 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
38 [DefaultProperty ("Cells")]
39 [ParseChildren (true, "Cells")]
42 [Designer ("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
43 public class TableRow : WebControl
45 TableCellCollection cells;
46 bool tableRowSectionSet;
48 internal TableRowCollection Container { get; set; }
51 : base (HtmlTextWriterTag.Tr)
56 internal bool TableRowSectionSet {
57 get { return tableRowSectionSet; }
60 [MergableProperty (false)]
61 [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
62 [WebSysDescription ("")]
63 [WebCategory("Layout")]
64 public virtual TableCellCollection Cells {
67 cells = new TableCellCollection (this);
72 [DefaultValue (HorizontalAlign.NotSet)]
73 [WebSysDescription ("")]
74 [WebCategory ("Layout")]
75 public virtual HorizontalAlign HorizontalAlign {
77 if (!ControlStyleCreated)
78 return HorizontalAlign.NotSet; // default value
79 return TableItemStyle.HorizontalAlign;
81 set { TableItemStyle.HorizontalAlign = value; }
84 [DefaultValue (VerticalAlign.NotSet)]
85 [WebSysDescription ("")]
86 [WebCategory ("Layout")]
87 public virtual VerticalAlign VerticalAlign {
89 if (!ControlStyleCreated)
90 return VerticalAlign.NotSet; // default value
91 return TableItemStyle.VerticalAlign;
93 set { TableItemStyle.VerticalAlign = value; }
96 TableItemStyle TableItemStyle {
97 get { return (ControlStyle as TableItemStyle); }
99 public override bool SupportsDisabledAttribute {
100 get { return RenderingCompatibilityLessThan40; }
102 protected override ControlCollection CreateControlCollection ()
104 return new CellControlCollection (this);
107 protected override Style CreateControlStyle ()
109 return new TableItemStyle (ViewState);
111 [DefaultValue (TableRowSection.TableBody)]
112 public virtual TableRowSection TableSection {
114 object o = ViewState ["TableSection"];
115 return (o == null) ? TableRowSection.TableBody : (TableRowSection) o;
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 ();
128 protected class CellControlCollection : ControlCollection {
130 internal CellControlCollection (TableRow owner)
136 public override void Add (Control child)
139 throw new NullReferenceException ("null");
140 if (!(child is TableCell))
141 throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
146 public override void AddAt (int index, Control child)
149 throw new NullReferenceException ("null");
150 if (!(child is TableCell))
151 throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
153 base.AddAt (index, child);