HtmlTableRow.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //
  2. // System.Web.UI.HtmlControls.HtmlTableRow.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.HtmlControls {
  31. // CAS
  32. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  33. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  34. // attributes
  35. [ParseChildren (true, "Cells")]
  36. public class HtmlTableRow : HtmlContainerControl {
  37. private HtmlTableCellCollection _cells;
  38. public HtmlTableRow ()
  39. : base ("tr")
  40. {
  41. }
  42. [DefaultValue ("")]
  43. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  44. [WebSysDescription("")]
  45. [WebCategory("Layout")]
  46. public string Align {
  47. get {
  48. string s = Attributes ["align"];
  49. return (s == null) ? String.Empty : s;
  50. }
  51. set {
  52. if (value == null)
  53. Attributes.Remove ("align");
  54. else
  55. Attributes ["align"] = value;
  56. }
  57. }
  58. [DefaultValue ("")]
  59. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  60. [WebSysDescription("")]
  61. [WebCategory("Appearance")]
  62. public string BgColor {
  63. get {
  64. string s = Attributes ["bgcolor"];
  65. return (s == null) ? String.Empty : s;
  66. }
  67. set {
  68. if (value == null)
  69. Attributes.Remove ("bgcolor");
  70. else
  71. Attributes ["bgcolor"] = value;
  72. }
  73. }
  74. [DefaultValue ("")]
  75. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  76. [WebSysDescription("")]
  77. [WebCategory("Appearance")]
  78. public string BorderColor {
  79. get {
  80. string s = Attributes ["bordercolor"];
  81. return (s == null) ? String.Empty : s;
  82. }
  83. set {
  84. if (value == null)
  85. Attributes.Remove ("bordercolor");
  86. else
  87. Attributes ["bordercolor"] = value;
  88. }
  89. }
  90. [Browsable (false)]
  91. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  92. public virtual HtmlTableCellCollection Cells {
  93. get {
  94. if (_cells == null)
  95. _cells = new HtmlTableCellCollection (this);
  96. return _cells;
  97. }
  98. }
  99. [DefaultValue ("")]
  100. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  101. [WebSysDescription("")]
  102. [WebCategory("Layout")]
  103. public string Height {
  104. get {
  105. string s = Attributes ["height"];
  106. return (s == null) ? String.Empty : s;
  107. }
  108. set {
  109. if (value == null)
  110. Attributes.Remove ("height");
  111. else
  112. Attributes ["height"] = value;
  113. }
  114. }
  115. public override string InnerHtml {
  116. get { throw new NotSupportedException (); }
  117. set { throw new NotSupportedException (); }
  118. }
  119. public override string InnerText {
  120. get { throw new NotSupportedException (); }
  121. set { throw new NotSupportedException (); }
  122. }
  123. [DefaultValue ("")]
  124. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  125. [WebSysDescription("")]
  126. [WebCategory("Layout")]
  127. public string VAlign {
  128. get {
  129. string s = Attributes ["valign"];
  130. return (s == null) ? String.Empty : s;
  131. }
  132. set {
  133. if (value == null)
  134. Attributes.Remove ("valign");
  135. else
  136. Attributes ["valign"] = value;
  137. }
  138. }
  139. private int Count {
  140. get { return (_cells == null) ? 0 : _cells.Count; }
  141. }
  142. protected override ControlCollection CreateControlCollection ()
  143. {
  144. return new HtmlTableCellControlCollection (this);
  145. }
  146. #if NET_2_0
  147. protected internal
  148. #else
  149. protected
  150. #endif
  151. override void RenderChildren (HtmlTextWriter writer)
  152. {
  153. if (HasControls ()) {
  154. writer.Indent++;
  155. base.RenderChildren (writer);
  156. writer.Indent--;
  157. writer.WriteLine ();
  158. }
  159. }
  160. protected override void RenderEndTag (HtmlTextWriter writer)
  161. {
  162. if (Count == 0)
  163. writer.WriteLine ();
  164. writer.WriteEndTag (TagName);
  165. if (writer.Indent == 0)
  166. writer.WriteLine ();
  167. }
  168. protected class HtmlTableCellControlCollection : ControlCollection {
  169. internal HtmlTableCellControlCollection (HtmlTableRow owner)
  170. : base (owner)
  171. {
  172. }
  173. public override void Add (Control child)
  174. {
  175. if (child == null)
  176. throw new NullReferenceException ("null");
  177. if (!(child is HtmlTableCell))
  178. throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableCell instance."));
  179. base.Add (child);
  180. }
  181. public override void AddAt (int index, Control child)
  182. {
  183. if (child == null)
  184. throw new NullReferenceException ("null");
  185. if (!(child is HtmlTableCell))
  186. throw new ArgumentException ("child", Locale.GetText ("Must be an HtmlTableCell instance."));
  187. base.AddAt (index, child);
  188. }
  189. }
  190. }
  191. }