TableRow.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. private TableCellCollection cells;
  44. public TableRow ()
  45. : base (HtmlTextWriterTag.Tr)
  46. {
  47. PreventAutoID ();
  48. }
  49. [MergableProperty (false)]
  50. [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
  51. [WebSysDescription ("")]
  52. [WebCategory("Layout")]
  53. public virtual TableCellCollection Cells {
  54. get {
  55. if (cells == null)
  56. cells = new TableCellCollection (this);
  57. return cells;
  58. }
  59. }
  60. #if ONLY_1_1
  61. [Bindable (true)]
  62. #endif
  63. [DefaultValue (HorizontalAlign.NotSet)]
  64. [WebSysDescription ("")]
  65. [WebCategory ("Layout")]
  66. public virtual HorizontalAlign HorizontalAlign {
  67. get {
  68. if (!ControlStyleCreated)
  69. return HorizontalAlign.NotSet; // default value
  70. return TableItemStyle.HorizontalAlign;
  71. }
  72. set { TableItemStyle.HorizontalAlign = value; }
  73. }
  74. #if ONLY_1_1
  75. [Bindable (true)]
  76. #endif
  77. [DefaultValue (VerticalAlign.NotSet)]
  78. [WebSysDescription ("")]
  79. [WebCategory ("Layout")]
  80. public virtual VerticalAlign VerticalAlign {
  81. get {
  82. if (!ControlStyleCreated)
  83. return VerticalAlign.NotSet; // default value
  84. return TableItemStyle.VerticalAlign;
  85. }
  86. set { TableItemStyle.VerticalAlign = value; }
  87. }
  88. private TableItemStyle TableItemStyle {
  89. get { return (ControlStyle as TableItemStyle); }
  90. }
  91. protected override ControlCollection CreateControlCollection ()
  92. {
  93. return new CellControlCollection (this);
  94. }
  95. protected override Style CreateControlStyle ()
  96. {
  97. return new TableItemStyle (ViewState);
  98. }
  99. #if NET_2_0
  100. [DefaultValue (TableRowSection.TableBody)]
  101. public virtual TableRowSection TableSection {
  102. get {
  103. object o = ViewState ["TableSection"];
  104. return (o == null) ? TableRowSection.TableBody : (TableRowSection) o;
  105. }
  106. set {
  107. if ((value < TableRowSection.TableHeader) || (value > TableRowSection.TableFooter))
  108. throw new ArgumentOutOfRangeException ("TableSection");
  109. ViewState ["TableSection"] = (int) value;
  110. }
  111. }
  112. #endif
  113. // inner class
  114. protected class CellControlCollection : ControlCollection {
  115. internal CellControlCollection (TableRow owner)
  116. : base (owner)
  117. {
  118. }
  119. public override void Add (Control child)
  120. {
  121. if (child == null)
  122. throw new NullReferenceException ("null");
  123. if (!(child is TableCell))
  124. throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
  125. base.Add (child);
  126. }
  127. public override void AddAt (int index, Control child)
  128. {
  129. if (child == null)
  130. throw new NullReferenceException ("null");
  131. if (!(child is TableCell))
  132. throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
  133. base.AddAt (index, child);
  134. }
  135. }
  136. }
  137. }