2
0

HtmlTableRow.cs 5.5 KB

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