|
1
|
|
#region Copyright
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
|
22
|
|
#endregion
|
|
23
|
|
|
|
24
|
|
using System.ComponentModel;
|
|
25
|
|
using System.Reflection;
|
|
26
|
|
using System.Web.UI;
|
|
27
|
|
using System.Web.UI.WebControls;
|
|
28
|
|
using ShowX.Config;
|
|
29
|
|
using ShowX.Model;
|
|
30
|
|
|
|
31
|
|
namespace ShowX.Web.WebControls
|
|
32
|
|
{
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
[DefaultProperty("Text"),
|
|
37
|
|
ToolboxData("<{0}:DataGrid runat=server></{0}:DataGrid>")]
|
|
38
|
|
public class CheckBoxList : ValidatedControl
|
|
39
|
|
{
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
protected PropertyInfo propertyInfo;
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
protected System.Web.UI.WebControls.CheckBoxList cblist;
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
|
|
54
|
|
|
|
55
|
29
|
public CheckBoxList(PropertyInfo propertyInfo) : base()
|
|
56
|
|
{
|
|
57
|
29
|
this.propertyInfo = propertyInfo;
|
|
58
|
|
}
|
|
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|
63
|
|
public ICollectionMap CollectionMap
|
|
64
|
|
{
|
|
65
|
10
|
get
|
|
66
|
|
{
|
|
67
|
10
|
return Configuration.Session.MappingHandler
|
|
68
|
|
.GetPropertyMap(propertyInfo) as ICollectionMap;
|
|
69
|
|
}
|
|
70
|
|
}
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
29
|
protected override void CreateChildControls()
|
|
76
|
|
{
|
|
77
|
29
|
base.CreateChildControls ();
|
|
78
|
29
|
this.cblist = new System.Web.UI.WebControls.CheckBoxList();
|
|
79
|
29
|
Controls.Add(cblist);
|
|
80
|
|
}
|
|
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
|
85
|
|
|
|
86
|
|
public ListItemCollection Items
|
|
87
|
|
{
|
|
88
|
115
|
get { return cblist.Items; }
|
|
89
|
|
}
|
|
90
|
|
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|
94
|
|
|
|
95
|
29
|
public override void MergeControlStyle(Style style)
|
|
96
|
|
{
|
|
97
|
29
|
EnsureChildControls();
|
|
98
|
29
|
cblist.MergeStyle(style);
|
|
99
|
29
|
messageL.MergeStyle(style);
|
|
100
|
|
}
|
|
101
|
|
|
|
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
6
|
public override bool Validate(object context)
|
|
109
|
|
{
|
|
110
|
6
|
string message = string.Empty;
|
|
111
|
6
|
Validated = true;
|
|
112
|
|
|
|
113
|
6
|
int selCant = 0;
|
|
114
|
|
|
|
115
|
6
|
foreach (ListItem il in this.Items)
|
|
116
|
18
|
if (il.Selected) selCant++;
|
|
117
|
|
|
|
118
|
6
|
foreach(IValidationMap val in Validators) {
|
|
119
|
|
|
|
120
|
6
|
if (!val.Validate(context,selCant.ToString())) {
|
|
121
|
|
|
|
122
|
2
|
message += " " + val.Message + ".";
|
|
123
|
2
|
Validated = false ;
|
|
124
|
|
|
|
125
|
|
}
|
|
126
|
|
}
|
|
127
|
|
|
|
128
|
6
|
messageL.Text = message;
|
|
129
|
6
|
return Validated;
|
|
130
|
|
}
|
|
131
|
|
|
|
132
|
|
|
|
133
|
|
|
|
134
|
|
|
|
135
|
|
|
|
136
|
25
|
protected override void Render(HtmlTextWriter writer)
|
|
137
|
|
{
|
|
138
|
25
|
writer.Write(@"
|
|
139
|
|
<table border=0 cellpadding=0 width=100%>
|
|
140
|
|
<tbody>
|
|
141
|
|
<tr>
|
|
142
|
|
<td>");
|
|
143
|
|
|
|
144
|
25
|
cblist.RenderControl(writer);
|
|
145
|
|
|
|
146
|
25
|
writer.Write(@"
|
|
147
|
|
</td>
|
|
148
|
|
</tr>");
|
|
149
|
|
|
|
150
|
25
|
if (!Validated) {
|
|
151
|
|
|
|
152
|
2
|
writer.Write(@"
|
|
153
|
|
<tr>
|
|
154
|
|
<td>");
|
|
155
|
|
|
|
156
|
2
|
messageL.RenderControl(writer);
|
|
157
|
|
|
|
158
|
2
|
writer.Write(@"
|
|
159
|
|
</td>
|
|
160
|
|
</tr>");
|
|
161
|
|
|
|
162
|
|
}
|
|
163
|
25
|
writer.Write(@"
|
|
164
|
|
</tbody>
|
|
165
|
|
</table>");
|
|
166
|
|
}
|
|
167
|
|
}
|
|
168
|
|
}
|
|
169
|
|
|