2
0

HtmlTableRow.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* System.Web.UI.HtmlControls
  2. * Authors
  3. * Leen Toelen ([email protected])
  4. */
  5. using System;
  6. using System.ComponentModel;
  7. using System.Web;
  8. using System.Web.UI;
  9. namespace System.Web.UI.HtmlControls{
  10. [ParseChildren(true, "Cells")]
  11. public class HtmlTableRow : HtmlContainerControl {
  12. private HtmlTableCellCollection _cells;
  13. public HtmlTableRow():base("tr"){}
  14. protected override ControlCollection CreateControlCollection(){
  15. return new HtmlTableCellControlCollection(this);
  16. }
  17. protected override void RenderChildren(HtmlTextWriter writer){
  18. writer.WriteLine();
  19. writer.Indent = writer.Indent + 1;
  20. base.RenderChildren(writer);
  21. writer.Indent = writer.Indent - 1;
  22. }
  23. protected override void RenderEndTag(HtmlTextWriter writer){
  24. base.RenderEndTag(writer);
  25. writer.WriteLine();
  26. }
  27. [DefaultValue("")]
  28. [WebCategory("Layout")]
  29. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  30. public string Align {
  31. get{
  32. string attr = Attributes["align"];
  33. if (attr != null) return attr;
  34. return String.Empty;
  35. }
  36. set{
  37. Attributes["align"] = AttributeToString(value);
  38. }
  39. }
  40. [DefaultValue("")]
  41. [WebCategory("Appearance")]
  42. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  43. public string BgColor {
  44. get{
  45. string attr = Attributes["bgcolor"];
  46. if (attr != null) return attr;
  47. return String.Empty;
  48. }
  49. set{
  50. Attributes["bgcolor"] = AttributeToString(value);
  51. }
  52. }
  53. [DefaultValue("")]
  54. [WebCategory("Appearance")]
  55. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  56. public string BorderColor {
  57. get{
  58. string attr = Attributes["bordercolor"];
  59. if (attr != null) return attr;
  60. return String.Empty;
  61. }
  62. set{
  63. Attributes["bordercolor"] = AttributeToString(value);
  64. }
  65. }
  66. [Browsable(false)]
  67. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  68. public virtual HtmlTableCellCollection Cells {
  69. get{
  70. if (_cells == null) _cells = new HtmlTableCellCollection(this);
  71. return _cells;
  72. }
  73. }
  74. [DefaultValue("")]
  75. [WebCategory("Layout")]
  76. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  77. public string Height {
  78. get{
  79. string attr = Attributes["height"];
  80. if (attr != null) return attr;
  81. return String.Empty;
  82. }
  83. set{
  84. Attributes["height"] = AttributeToString(value);
  85. }
  86. }
  87. public override string InnerHtml {
  88. get{
  89. throw new NotSupportedException("InnerHtml is not supported by HtmlTableRow");
  90. }
  91. set{
  92. throw new NotSupportedException("InnerHtml is not supported by HtmlTableRow");
  93. }
  94. }
  95. public override string InnerText {
  96. get{
  97. throw new NotSupportedException("InnerText is not supported by HtmlTableRow");
  98. }
  99. set{
  100. throw new NotSupportedException("InnerText is not supported by HtmlTableRow");
  101. }
  102. }
  103. [DefaultValue("")]
  104. [WebCategory("Layout")]
  105. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  106. public string VAlign {
  107. get{
  108. string attr = Attributes["valign"];
  109. if (attr != null) return attr;
  110. return String.Empty;
  111. }
  112. set{
  113. Attributes["valign"] = AttributeToString(value);
  114. }
  115. }
  116. protected class HtmlTableCellControlCollection : ControlCollection {
  117. internal HtmlTableCellControlCollection(Control owner): base(owner){}
  118. public override void Add(Control child){
  119. if (child is HtmlTableCell){
  120. base.Add(child);
  121. }
  122. else{
  123. throw new ArgumentException("HtmlTableRow cannot have children of Type " + child.GetType().Name);
  124. }
  125. }
  126. public override void AddAt(int index, Control child){
  127. if (child is HtmlTableCell){
  128. base.AddAt(index,child);
  129. }
  130. else{
  131. throw new ArgumentException("HtmlTableRow cannot have children of Type " + child.GetType().Name);
  132. }
  133. }
  134. }
  135. } // end of System.Web.UI.HtmlControls.HtmlTableRow+HtmlTableCellControlCollection
  136. // end of System.Web.UI.HtmlControls.HtmlTableRow
  137. }