Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HtmlTable.cs « System.Web.UI.HtmlControls « System.Web « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a70743c2d0b5dc6a61350ad305913f25e20ec4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*	System.Web.UI.HtmlControls
*	Authors
*		Leen Toelen (toelen@hotmail.com)
*/

using System;
using System.Web;
using System.Web.UI;
using System.Globalization;

namespace System.Web.UI.HtmlControls{
	
	public class HtmlTable : HtmlContainerControl {
		private HtmlTableRowCollection _rows;
		
		public HtmlTable():base("table"){}
		
		protected override ControlCollection CreateControlCollection(){
			return new HtmlTableRowControlCollection(this);
		}
		
		protected override void RenderChildren(HtmlTextWriter writer){
			writer.WriteLine();
			writer.Indent = writer.Indent + 1;
			base.RenderChildren(writer);
			writer.Indent = writer.Indent - 1;
		}
		
		protected override void RenderEndTag(HtmlTextWriter writer){
			base.RenderEndTag(writer);
			writer.WriteLine();
		}
		
		public string Align {
			get{
				string attr = Attributes["align"];
				if (attr != null) return attr;
				return String.Empty;
			}
			set{
				Attributes["align"] = AttributeToString(value);
			}
		}
		
		public string BgColor {
			get{
				string attr = Attributes["bgcolor"];
				if (attr != null) return attr;
				return String.Empty;
			}
			set{
				Attributes["bgcolor"] = AttributeToString(value);
			}
		}
		
		public int Border {
			get{
				string attr = Attributes["border"];
				if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
				return -1;
			}
			set{
				Attributes["border"] = AttributeToString(value);
			}
		}
		
		public string BorderColor {
			get{
				string attr = Attributes["bordercolor"];
				if (attr != null) return attr;
				return String.Empty;
			}
			set{
				Attributes["bordercolor"] = AttributeToString(value);
			}
		}
		
		public int CellPadding {
			get{
				string attr = Attributes["cellpadding"];
				if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
				return -1;
			}
			set{
				Attributes["cellpadding"] = AttributeToString(value);
			}
		}
		
		public int CellSpacing {
			get{
				string attr = Attributes["cellspacing"];
				if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
				return -1;
			}
			set{
				Attributes["cellspacing"] = AttributeToString(value);
			}
		}
		
		public string Height {
			get{
				string attr = Attributes["height"];
				if (attr != null) return attr;
				return String.Empty;
			}
			set{
				Attributes["height"] = AttributeToString(value);
			}
		}
		
		public override string InnerHtml {
			get{
				throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
			}
			set{
				throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
			}
		}
		
		public override string InnerText {
			get{
				throw new NotSupportedException("InnerText property not supported by HtmlTable");
			}
			set{
				throw new NotSupportedException("InnerText property not supported by HtmlTable");
			}
		}
		
		public virtual HtmlTableRowCollection Rows {
			get{
				if (_rows == null) _rows = new HtmlTableRowCollection(this);
				return _rows;
			}
		}
		
		public string Width {
			get{
				string attr = Attributes["width"];
				if (attr != null) return attr;
				return String.Empty;
			}
			set{
				Attributes["width"] = AttributeToString(value);
			}
		}
		
		protected class HtmlTableRowControlCollection : ControlCollection {
			
			internal HtmlTableRowControlCollection(Control owner): base(owner){}
			
			public override void Add(Control child){
				if ((child as HtmlTableRow) != null){
					base.Add(child);
				}
				else{
					throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
				}
			}
			
			public override void AddAt(int index, Control child){
				if ((child as HtmlTableRow) != null){
					base.AddAt(index,child);
				}
				else{
					throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
				}
			}
		} // end of HtmlTableRowControlCollection
	}
	// end of System.Web.UI.HtmlControl
}