HtmlTableCell.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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.Globalization;
  30. using System.Security.Permissions;
  31. using System.Web.Util;
  32. namespace System.Web.UI.HtmlControls
  33. {
  34. // CAS
  35. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  36. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  37. // attributes
  38. [ConstructorNeedsTag (true)]
  39. public class HtmlTableCell : HtmlContainerControl
  40. {
  41. public HtmlTableCell ()
  42. : base ("td")
  43. {
  44. }
  45. public HtmlTableCell (string tagName)
  46. : base (tagName)
  47. {
  48. }
  49. [DefaultValue ("")]
  50. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  51. [WebSysDescription("")]
  52. [WebCategory("Layout")]
  53. public string Align {
  54. get {
  55. string s = Attributes ["align"];
  56. return (s == null) ? String.Empty : s;
  57. }
  58. set {
  59. if (value == null)
  60. Attributes.Remove ("align");
  61. else
  62. Attributes ["align"] = value;
  63. }
  64. }
  65. [DefaultValue ("")]
  66. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  67. [WebSysDescription("")]
  68. [WebCategory("Appearance")]
  69. public string BgColor {
  70. get {
  71. string s = Attributes ["bgcolor"];
  72. return (s == null) ? String.Empty : s;
  73. }
  74. set {
  75. if (value == null)
  76. Attributes.Remove ("bgcolor");
  77. else
  78. Attributes ["bgcolor"] = value;
  79. }
  80. }
  81. [DefaultValue ("")]
  82. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  83. [WebSysDescription("")]
  84. [WebCategory("Appearance")]
  85. public string BorderColor {
  86. get {
  87. string s = Attributes ["bordercolor"];
  88. return (s == null) ? String.Empty : s;
  89. }
  90. set {
  91. if (value == null)
  92. Attributes.Remove ("bordercolor");
  93. else
  94. Attributes ["bordercolor"] = value;
  95. }
  96. }
  97. [DefaultValue ("")]
  98. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  99. [WebSysDescription("")]
  100. [WebCategory("Layout")]
  101. public int ColSpan {
  102. get {
  103. string s = Attributes ["colspan"];
  104. return (s == null) ? -1 : Convert.ToInt32 (s);
  105. }
  106. set {
  107. if (value == -1)
  108. Attributes.Remove ("colspan");
  109. else
  110. Attributes ["colspan"] = value.ToString (Helpers.InvariantCulture);
  111. }
  112. }
  113. [DefaultValue ("")]
  114. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  115. [WebSysDescription("")]
  116. [WebCategory("Layout")]
  117. public string Height {
  118. get {
  119. string s = Attributes ["height"];
  120. return (s == null) ? String.Empty : s;
  121. }
  122. set {
  123. if (value == null)
  124. Attributes.Remove ("align");
  125. else
  126. Attributes ["height"] = value;
  127. }
  128. }
  129. [DefaultValue ("")]
  130. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  131. [TypeConverter (typeof (MinimizableAttributeTypeConverter))]
  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. }