HtmlTableCell.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.Globalization;
  30. using System.Security.Permissions;
  31. namespace System.Web.UI.HtmlControls {
  32. // CAS
  33. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  34. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  35. // attributes
  36. [ConstructorNeedsTag (true)]
  37. public class HtmlTableCell : HtmlContainerControl {
  38. public HtmlTableCell ()
  39. : base ("td")
  40. {
  41. }
  42. public HtmlTableCell (string tagName)
  43. : base (tagName)
  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. [DefaultValue ("")]
  95. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  96. [WebSysDescription("")]
  97. [WebCategory("Layout")]
  98. public int ColSpan {
  99. get {
  100. string s = Attributes ["colspan"];
  101. return (s == null) ? -1 : Convert.ToInt32 (s);
  102. }
  103. set {
  104. if (value == -1)
  105. Attributes.Remove ("colspan");
  106. else
  107. Attributes ["colspan"] = value.ToString (CultureInfo.InvariantCulture);
  108. }
  109. }
  110. [DefaultValue ("")]
  111. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  112. [WebSysDescription("")]
  113. [WebCategory("Layout")]
  114. public string Height {
  115. get {
  116. string s = Attributes ["height"];
  117. return (s == null) ? String.Empty : s;
  118. }
  119. set {
  120. if (value == null)
  121. Attributes.Remove ("align");
  122. else
  123. Attributes ["height"] = value;
  124. }
  125. }
  126. [DefaultValue ("")]
  127. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  128. #if NET_2_0
  129. [TypeConverter (typeof (MinimizableAttributeTypeConverter))]
  130. #endif
  131. [WebSysDescription("")]
  132. [WebCategory("Behavior")]
  133. public bool NoWrap {
  134. get { return (Attributes ["nowrap"] == "nowrap"); }
  135. set {
  136. if (value)
  137. Attributes ["nowrap"] = "nowrap";
  138. else
  139. Attributes.Remove ("nowrap");
  140. }
  141. }
  142. [DefaultValue ("")]
  143. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  144. [WebSysDescription("")]
  145. [WebCategory("Layout")]
  146. public int RowSpan {
  147. get {
  148. string s = Attributes ["rowspan"];
  149. return (s == null) ? -1 : Convert.ToInt32 (s);
  150. }
  151. set {
  152. if (value == -1)
  153. Attributes.Remove ("rowspan");
  154. else
  155. Attributes ["rowspan"] = value.ToString (CultureInfo.InvariantCulture);
  156. }
  157. }
  158. [DefaultValue ("")]
  159. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  160. [WebSysDescription("")]
  161. [WebCategory("Appearance")]
  162. public string VAlign {
  163. get {
  164. string s = Attributes ["valign"];
  165. return (s == null) ? String.Empty : s;
  166. }
  167. set {
  168. if (value == null)
  169. Attributes.Remove ("valign");
  170. else
  171. Attributes ["valign"] = value;
  172. }
  173. }
  174. [DefaultValue ("")]
  175. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  176. [WebSysDescription("")]
  177. [WebCategory("Layout")]
  178. public string Width {
  179. get {
  180. string s = Attributes ["width"];
  181. return (s == null) ? String.Empty : s;
  182. }
  183. set {
  184. if (value == null)
  185. Attributes.Remove ("width");
  186. else
  187. Attributes ["width"] = value;
  188. }
  189. }
  190. protected override void RenderEndTag (HtmlTextWriter writer)
  191. {
  192. writer.WriteEndTag (TagName);
  193. if (writer.Indent == 0)
  194. writer.WriteLine ();
  195. }
  196. }
  197. }