HtmlTableRow.cs 5.7 KB

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