HtmlTableCell.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. using System.Web.Util;
  32. namespace System.Web.UI.HtmlControls {
  33. // CAS
  34. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  35. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  36. // attributes
  37. [ConstructorNeedsTag (true)]
  38. public class HtmlTableCell : HtmlContainerControl {
  39. public HtmlTableCell ()
  40. : base ("td")
  41. {
  42. }
  43. public HtmlTableCell (string tagName)
  44. : base (tagName)
  45. {
  46. }
  47. [DefaultValue ("")]
  48. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  49. [WebSysDescription("")]
  50. [WebCategory("Layout")]
  51. public string Align {
  52. get {
  53. string s = Attributes ["align"];
  54. return (s == null) ? String.Empty : s;
  55. }
  56. set {
  57. if (value == null)
  58. Attributes.Remove ("align");
  59. else
  60. Attributes ["align"] = value;
  61. }
  62. }
  63. [DefaultValue ("")]
  64. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  65. [WebSysDescription("")]
  66. [WebCategory("Appearance")]
  67. public string BgColor {
  68. get {
  69. string s = Attributes ["bgcolor"];
  70. return (s == null) ? String.Empty : s;
  71. }
  72. set {
  73. if (value == null)
  74. Attributes.Remove ("bgcolor");
  75. else
  76. Attributes ["bgcolor"] = value;
  77. }
  78. }
  79. [DefaultValue ("")]
  80. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  81. [WebSysDescription("")]
  82. [WebCategory("Appearance")]
  83. public string BorderColor {
  84. get {
  85. string s = Attributes ["bordercolor"];
  86. return (s == null) ? String.Empty : s;
  87. }
  88. set {
  89. if (value == null)
  90. Attributes.Remove ("bordercolor");
  91. else
  92. Attributes ["bordercolor"] = value;
  93. }
  94. }
  95. [DefaultValue ("")]
  96. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  97. [WebSysDescription("")]
  98. [WebCategory("Layout")]
  99. public int ColSpan {
  100. get {
  101. string s = Attributes ["colspan"];
  102. return (s == null) ? -1 : Convert.ToInt32 (s);
  103. }
  104. set {
  105. if (value == -1)
  106. Attributes.Remove ("colspan");
  107. else
  108. Attributes ["colspan"] = value.ToString (Helpers.InvariantCulture);
  109. }
  110. }
  111. [DefaultValue ("")]
  112. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  113. [WebSysDescription("")]
  114. [WebCategory("Layout")]
  115. public string Height {
  116. get {
  117. string s = Attributes ["height"];
  118. return (s == null) ? String.Empty : s;
  119. }
  120. set {
  121. if (value == null)
  122. Attributes.Remove ("align");
  123. else
  124. Attributes ["height"] = value;
  125. }
  126. }
  127. [DefaultValue ("")]
  128. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  129. #if NET_2_0
  130. [TypeConverter (typeof (MinimizableAttributeTypeConverter))]
  131. #endif
  132. [WebSysDescription("")]
  133. [WebCategory("Behavior")]
  134. public bool NoWrap {
  135. get { return (Attributes ["nowrap"] == "nowrap"); }
  136. set {
  137. if (value)
  138. Attributes ["nowrap"] = "nowrap";
  139. else
  140. Attributes.Remove ("nowrap");
  141. }
  142. }
  143. [DefaultValue ("")]
  144. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  145. [WebSysDescription("")]
  146. [WebCategory("Layout")]
  147. public int RowSpan {
  148. get {
  149. string s = Attributes ["rowspan"];
  150. return (s == null) ? -1 : Convert.ToInt32 (s);
  151. }
  152. set {
  153. if (value == -1)
  154. Attributes.Remove ("rowspan");
  155. else
  156. Attributes ["rowspan"] = value.ToString (Helpers.InvariantCulture);
  157. }
  158. }
  159. [DefaultValue ("")]
  160. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  161. [WebSysDescription("")]
  162. [WebCategory("Appearance")]
  163. public string VAlign {
  164. get {
  165. string s = Attributes ["valign"];
  166. return (s == null) ? String.Empty : s;
  167. }
  168. set {
  169. if (value == null)
  170. Attributes.Remove ("valign");
  171. else
  172. Attributes ["valign"] = value;
  173. }
  174. }
  175. [DefaultValue ("")]
  176. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  177. [WebSysDescription("")]
  178. [WebCategory("Layout")]
  179. public string Width {
  180. get {
  181. string s = Attributes ["width"];
  182. return (s == null) ? String.Empty : s;
  183. }
  184. set {
  185. if (value == null)
  186. Attributes.Remove ("width");
  187. else
  188. Attributes ["width"] = value;
  189. }
  190. }
  191. protected override void RenderEndTag (HtmlTextWriter writer)
  192. {
  193. writer.WriteEndTag (TagName);
  194. if (writer.Indent == 0)
  195. writer.WriteLine ();
  196. }
  197. }
  198. }