TableRow.cs 4.9 KB

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