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;
|
25
|
|
using System.ComponentModel;
|
26
|
|
using System.Reflection;
|
27
|
|
using System.Web.UI;
|
28
|
|
using System.Web.UI.WebControls;
|
29
|
|
using System.Web.UI.HtmlControls;
|
30
|
|
using ShowX.Config;
|
31
|
|
using ShowX.Model;
|
32
|
|
using ShowX.Web.Scripts;
|
33
|
|
|
34
|
|
namespace ShowX.Web.WebControls
|
35
|
|
{
|
36
|
|
|
37
|
|
|
38
|
|
|
39
|
|
[DefaultProperty("Text"),
|
40
|
|
ToolboxData("<{0}:DataGrid runat=server></{0}:DataGrid>")]
|
41
|
|
public class Calendar : ValidatedControl
|
42
|
|
{
|
43
|
|
|
44
|
|
|
45
|
|
|
46
|
|
protected PropertyInfo propertyInfo;
|
47
|
|
|
48
|
|
|
49
|
|
|
50
|
|
|
51
|
|
protected System.Web.UI.WebControls.TextBox calendarText;
|
52
|
|
|
53
|
|
|
54
|
|
|
55
|
|
|
56
|
|
protected System.Web.UI.HtmlControls.HtmlButton activationBtn;
|
57
|
|
|
58
|
|
|
59
|
|
|
60
|
|
|
61
|
|
|
62
|
|
|
63
|
29
|
public Calendar(PropertyInfo propertyInfo) : base()
|
64
|
|
{
|
65
|
29
|
this.propertyInfo = propertyInfo;
|
66
|
|
}
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
0
|
public ICollectionMap CollectionMap
|
72
|
|
{
|
73
|
|
get
|
74
|
|
{
|
75
|
|
return Configuration.Session.MappingHandler
|
76
|
|
.GetPropertyMap(propertyInfo) as ICollectionMap;
|
77
|
|
}
|
78
|
|
}
|
79
|
|
|
80
|
|
|
81
|
|
|
82
|
|
|
83
|
|
|
84
|
29
|
protected override void OnLoad(EventArgs e)
|
85
|
|
{
|
86
|
29
|
CreateChildControls();
|
87
|
|
}
|
88
|
|
|
89
|
|
|
90
|
|
|
91
|
|
|
92
|
58
|
protected override void CreateChildControls()
|
93
|
|
{
|
94
|
58
|
base.CreateChildControls();
|
95
|
|
|
96
|
58
|
if (this.Page != null)
|
97
|
33
|
new IncludeJSCalendarScriptBlock().Register(this.Page);
|
98
|
|
|
99
|
58
|
calendarText = new TextBox();
|
100
|
58
|
calendarText.Text = "(not specified)";
|
101
|
58
|
calendarText.ReadOnly = true;
|
102
|
58
|
activationBtn = new HtmlButton();
|
103
|
58
|
activationBtn.InnerText = "...";
|
104
|
58
|
activationBtn.ID = System.Guid.NewGuid().ToString();
|
105
|
58
|
Controls.Add(calendarText);
|
106
|
58
|
Controls.Add(activationBtn);
|
107
|
|
}
|
108
|
|
|
109
|
|
|
110
|
|
|
111
|
|
|
112
|
|
|
113
|
|
public string SelectedDate
|
114
|
|
{
|
115
|
5
|
get
|
116
|
|
{
|
117
|
5
|
EnsureChildControls();
|
118
|
5
|
return this.calendarText.Text;
|
119
|
|
}
|
120
|
|
|
121
|
4
|
set
|
122
|
|
{
|
123
|
4
|
EnsureChildControls();
|
124
|
4
|
this.calendarText.Text = value;
|
125
|
|
}
|
126
|
|
}
|
127
|
|
|
128
|
|
|
129
|
|
|
130
|
|
|
131
|
|
|
132
|
54
|
public override void MergeControlStyle(Style style)
|
133
|
|
{
|
134
|
54
|
EnsureChildControls();
|
135
|
54
|
calendarText.MergeStyle(style);
|
136
|
54
|
messageL.ControlStyle.MergeWith(style);
|
137
|
|
}
|
138
|
|
|
139
|
|
|
140
|
|
|
141
|
|
|
142
|
|
|
143
|
|
|
144
|
|
|
145
|
4
|
public override bool Validate(object context)
|
146
|
|
{
|
147
|
4
|
Validated = true;
|
148
|
|
|
149
|
4
|
try {
|
150
|
|
|
151
|
4
|
Convert.ToDateTime(calendarText.Text);
|
152
|
|
}
|
153
|
|
catch {
|
154
|
|
|
155
|
1
|
Validated = false;
|
156
|
1
|
messageL.Text = "You have to select a valid date";
|
157
|
|
}
|
158
|
|
|
159
|
4
|
return Validated;
|
160
|
|
}
|
161
|
|
|
162
|
|
|
163
|
|
|
164
|
|
|
165
|
|
|
166
|
25
|
protected override void Render(HtmlTextWriter writer)
|
167
|
|
{
|
168
|
25
|
writer.Write(@"
|
169
|
|
<table border=0 cellpadding=0 width=100%>
|
170
|
|
<tbody>
|
171
|
|
<tr>
|
172
|
|
<td>");
|
173
|
|
|
174
|
25
|
calendarText.RenderControl(writer);
|
175
|
|
|
176
|
25
|
writer.Write(@"
|
177
|
|
</td><td>");
|
178
|
|
|
179
|
25
|
activationBtn.RenderControl(writer);
|
180
|
25
|
writer.Write("</td></tr>");
|
181
|
|
|
182
|
25
|
if (!Validated) {
|
183
|
|
|
184
|
1
|
writer.Write(@"
|
185
|
|
<tr>
|
186
|
|
<td colspan=2>");
|
187
|
|
|
188
|
1
|
messageL.RenderControl(writer);
|
189
|
|
|
190
|
1
|
writer.Write(@"
|
191
|
|
</td>
|
192
|
|
</tr>");
|
193
|
|
}
|
194
|
25
|
writer.Write(@"
|
195
|
|
</tbody>
|
196
|
|
</table>");
|
197
|
|
|
198
|
25
|
new JSCalendarSetupScriptBlock(calendarText.UniqueID,activationBtn.ClientID)
|
199
|
|
.Register(this.Page);
|
200
|
|
}
|
201
|
|
}
|
202
|
|
}
|
203
|
|
|