2
0

HtmlTableRow.cs 3.3 KB

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