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.Web.UI;
|
26
|
|
using System.Web.UI.WebControls;
|
27
|
|
using ShowX.Model;
|
28
|
|
|
29
|
|
namespace ShowX.Web.WebControls
|
30
|
|
{
|
31
|
|
|
32
|
|
|
33
|
|
|
34
|
|
|
35
|
|
[DefaultProperty("Text"),
|
36
|
|
ToolboxData("<{0}:ChangePassword runat=server></{0}:ChangePassword>")]
|
37
|
|
public class ChangePassword : ValidatedControl
|
38
|
|
{
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
|
protected TextBox passTB1;
|
43
|
|
|
44
|
|
|
45
|
|
|
46
|
|
|
47
|
|
protected TextBox passTB2;
|
48
|
|
|
49
|
|
|
50
|
|
|
51
|
|
|
52
|
29
|
public ChangePassword()
|
53
|
|
{
|
54
|
29
|
Controls.Add(passTB1 = new TextBox());
|
55
|
29
|
Controls.Add(passTB2 = new TextBox());
|
56
|
29
|
passTB1.TextMode = TextBoxMode.Password;
|
57
|
29
|
passTB1.Width = Unit.Percentage(100);
|
58
|
29
|
passTB2.TextMode = TextBoxMode.Password;
|
59
|
29
|
passTB2.Width = Unit.Percentage(100);
|
60
|
29
|
messageL.Text = "don't match";
|
61
|
|
}
|
62
|
|
|
63
|
|
|
64
|
|
|
65
|
|
|
66
|
|
|
67
|
6
|
public override bool Validate(object context)
|
68
|
|
{
|
69
|
6
|
string message = string.Empty;
|
70
|
6
|
Validated = true;
|
71
|
|
|
72
|
6
|
foreach(IValidationMap val in Validators) {
|
73
|
|
|
74
|
12
|
if (!val.Validate(context,passTB1.Text)) {
|
75
|
|
|
76
|
4
|
message += " " + val.Message + ".";
|
77
|
4
|
Validated = false ;
|
78
|
|
|
79
|
|
}
|
80
|
|
}
|
81
|
|
|
82
|
6
|
if (passTB1.Text != passTB2.Text) {
|
83
|
|
|
84
|
0
|
message += " Passwords don't match.";
|
85
|
0
|
Validated = false ;
|
86
|
|
}
|
87
|
|
|
88
|
6
|
messageL.Text = message;
|
89
|
|
|
90
|
6
|
return Validated;
|
91
|
|
}
|
92
|
|
|
93
|
|
|
94
|
|
|
95
|
|
|
96
|
|
public string Password
|
97
|
|
{
|
98
|
4
|
get { return passTB1.Text; }
|
99
|
|
}
|
100
|
|
|
101
|
|
|
102
|
|
|
103
|
|
|
104
|
|
|
105
|
29
|
public override void MergeControlStyle(Style style)
|
106
|
|
{
|
107
|
29
|
passTB1.MergeStyle(style);
|
108
|
29
|
passTB2.MergeStyle(style);
|
109
|
|
}
|
110
|
|
|
111
|
|
|
112
|
|
|
113
|
|
|
114
|
|
|
115
|
25
|
protected override void Render(HtmlTextWriter writer)
|
116
|
|
{
|
117
|
25
|
writer.Write(@"
|
118
|
|
<table border=0 cellpadding=0 width=100%>
|
119
|
|
<tbody>
|
120
|
|
<tr>
|
121
|
|
<td>");
|
122
|
|
|
123
|
25
|
passTB1.RenderControl(writer);
|
124
|
|
|
125
|
25
|
writer.Write(@"
|
126
|
|
</td>
|
127
|
|
</tr>
|
128
|
|
<tr>
|
129
|
|
<td>");
|
130
|
|
|
131
|
25
|
passTB2.RenderControl(writer);
|
132
|
|
|
133
|
25
|
writer.Write(@"
|
134
|
|
</td>
|
135
|
|
</tr>");
|
136
|
|
|
137
|
25
|
if (!Validated) {
|
138
|
|
|
139
|
2
|
writer.Write(@"
|
140
|
|
<tr>
|
141
|
|
<td>");
|
142
|
|
|
143
|
2
|
messageL.RenderControl(writer);
|
144
|
2
|
writer.Write(@"
|
145
|
|
</td>
|
146
|
|
</tr>");
|
147
|
|
|
148
|
|
}
|
149
|
25
|
writer.Write(@"
|
150
|
|
</tbody>
|
151
|
|
</table>");
|
152
|
|
}
|
153
|
|
}
|
154
|
|
}
|