2 // System.Web.UI.WebControls.TableCell.cs
5 // Gaurav Vaish (gvaish@iitk.ac.in)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
13 using System.Globalization;
\r
15 using System.Web.UI;
\r
16 using System.ComponentModel;
\r
18 namespace System.Web.UI.WebControls
\r
20 [DefaultProperty("Text")]
\r
21 [ToolboxItem(false)]
\r
22 [ControlBuilder(typeof(TableCellControlBuilder))]
\r
23 [ParseChildren(false)]
\r
24 [PersistChildren(true)]
\r
25 public class TableCell: WebControl
\r
27 public TableCell () : base (HtmlTextWriterTag.Td)
\r
32 internal TableCell (HtmlTextWriterTag tag) : base (tag)
\r
37 [DefaultValue (0), Bindable (true), WebCategory ("Appearance")]
38 [WebSysDescription ("The number of columns spanned by this cell.")]
\r
39 public virtual int ColumnSpan
\r
42 object o = ViewState ["ColumnSpan"];
\r
43 return (o == null) ? 0 : (int) o;
\r
48 throw new ArgumentOutOfRangeException ("value", "ColumnSpan value has to be >= 0.");
49 ViewState ["ColumnSpan"] = value;
53 [DefaultValue (0), Bindable (true), WebCategory ("Layout")]
54 [WebSysDescription ("The number of rows spanned by this cell.")]
\r
55 public virtual int RowSpan
\r
58 object o = ViewState ["RowSpan"];
\r
59 return (o == null) ? 0 : (int) o;
\r
64 throw new ArgumentOutOfRangeException ("value", "RowSpan value has to be >= 0.");
65 ViewState ["RowSpan"] = value;
69 [DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
70 [WebSysDescription ("The text that is shown in this cell.")]
\r
71 public virtual string Text
\r
74 object o = ViewState ["Text"];
\r
75 return (o == null) ? String.Empty : (string) o;
\r
81 ViewState ["Text"] = value;
85 [DefaultValue (typeof (HorizontalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
86 [WebSysDescription ("The horizontal alignment for this cell.")]
\r
87 public virtual HorizontalAlign HorizontalAlign
\r
90 if (ControlStyleCreated)
\r
91 return ((TableItemStyle) ControlStyle).HorizontalAlign;
\r
92 return HorizontalAlign.NotSet;
\r
94 set { ((TableItemStyle) ControlStyle).HorizontalAlign = value; }
\r
97 [DefaultValue (typeof (VerticalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
98 [WebSysDescription ("The horizontal alignment for this cell.")]
\r
99 public virtual VerticalAlign VerticalAlign
\r
102 if (ControlStyleCreated)
\r
103 return ((TableItemStyle) ControlStyle).VerticalAlign;
\r
104 return VerticalAlign.NotSet;
\r
107 set { ((TableItemStyle) ControlStyle).VerticalAlign = value; }
\r
110 [DefaultValue (true), Bindable (true), WebCategory ("Layout")]
111 [WebSysDescription ("Determines if the text in the cell should be wraped at line-end.")]
\r
112 public virtual bool Wrap
\r
115 if (ControlStyleCreated)
\r
116 return ((TableItemStyle) ControlStyle).Wrap;
\r
119 set { ((TableItemStyle) ControlStyle).Wrap = value; }
\r
122 protected override void AddAttributesToRender (HtmlTextWriter writer)
\r
124 base.AddAttributesToRender (writer);
\r
125 if (ColumnSpan > 0)
\r
126 writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
\r
127 ColumnSpan.ToString (NumberFormatInfo.InvariantInfo));
\r
130 writer.AddAttribute (HtmlTextWriterAttribute.Rowspan,
\r
131 RowSpan.ToString (NumberFormatInfo.InvariantInfo));
\r
134 protected override void AddParsedSubObject (object obj)
\r
136 if (HasControls ()){
\r
137 base.AddParsedSubObject (obj);
\r
141 if (obj is LiteralControl){
\r
142 Text = ((LiteralControl) obj).Text;
\r
146 string text = Text;
\r
147 if (text.Length > 0){
\r
148 Text = String.Empty;
\r
149 base.AddParsedSubObject (new LiteralControl (text));
\r
152 base.AddParsedSubObject (obj);
\r
155 protected override Style CreateControlStyle ()
\r
157 return new TableItemStyle (ViewState);
\r
160 protected override void RenderContents (HtmlTextWriter writer)
\r
162 if (HasControls ())
\r
163 base.RenderContents (writer);
\r
165 writer.Write (Text);
\r