2 // System.Web.UI.WebControls.ChangePassword.cs
5 // Igor Zelmanovich (igorz@mainsoft.com)
6 // Vladimir Krasnov (vladimirk@mainsoft.com)
8 // (C) 2006 Mainsoft, Inc (http://www.mainsoft.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Web.Security;
32 using System.Collections.Generic;
33 using System.Collections.Specialized;
36 using System.ComponentModel;
37 using System.Collections;
38 using System.Net.Mail;
40 namespace System.Web.UI.WebControls
43 [DefaultEvent ("ChangedPassword")]
44 [Designer ("System.Web.UI.Design.WebControls.ChangePasswordDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
45 public class ChangePassword : CompositeControl, INamingContainer
48 static readonly object cancelButtonClickEvent = new object ();
49 static readonly object changedPasswordEvent = new object ();
50 static readonly object changePasswordErrorEvent = new object ();
51 static readonly object changingPasswordEvent = new object ();
52 static readonly object continueButtonClickEvent = new object ();
53 static readonly object sendingMailEvent = new object ();
54 static readonly object sendMailErrorEvent = new object ();
56 public static readonly string CancelButtonCommandName = "Cancel";
57 public static readonly string ChangePasswordButtonCommandName = "ChangePassword";
58 public static readonly string ContinueButtonCommandName = "Continue";
59 bool renderOuterTable = true;
60 Style _cancelButtonStyle = null;
61 Style _changePasswordButtonStyle = null;
62 Style _continueButtonStyle = null;
63 TableItemStyle _failureTextStyle = null;
64 TableItemStyle _hyperLinkStyle = null;
65 TableItemStyle _instructionTextStyle = null;
66 TableItemStyle _labelStyle = null;
67 TableItemStyle _passwordHintStyle = null;
68 TableItemStyle _successTextStyle = null;
69 Style _textBoxStyle = null;
70 TableItemStyle _titleTextStyle = null;
71 Style _validatorTextStyle = null;
73 MailDefinition _mailDefinition = null;
74 MembershipProvider _provider = null;
76 ITemplate _changePasswordTemplate = null;
77 ITemplate _successTemplate = null;
79 Control _changePasswordTemplateContainer = null;
80 Control _successTemplateContainer = null;
82 string _username = null;
83 string _currentPassword = null;
84 string _newPassword = null;
85 string _newPasswordConfirm = null;
87 bool _showContinue = false;
89 EventHandlerList events = new EventHandlerList ();
92 public event EventHandler CancelButtonClick {
93 add { events.AddHandler (cancelButtonClickEvent, value); }
94 remove { events.RemoveHandler (cancelButtonClickEvent, value); }
97 public event EventHandler ChangedPassword {
98 add { events.AddHandler (changedPasswordEvent, value); }
99 remove { events.RemoveHandler (changedPasswordEvent, value); }
102 public event EventHandler ChangePasswordError {
103 add { events.AddHandler (changePasswordErrorEvent, value); }
104 remove { events.RemoveHandler (changePasswordErrorEvent, value); }
107 public event LoginCancelEventHandler ChangingPassword {
108 add { events.AddHandler (changingPasswordEvent, value); }
109 remove { events.RemoveHandler (changingPasswordEvent, value); }
112 public event EventHandler ContinueButtonClick {
113 add { events.AddHandler (continueButtonClickEvent, value); }
114 remove { events.RemoveHandler (continueButtonClickEvent, value); }
117 public event MailMessageEventHandler SendingMail {
118 add { events.AddHandler (sendingMailEvent, value); }
119 remove { events.RemoveHandler (sendingMailEvent, value); }
122 public event SendMailErrorEventHandler SendMailError {
123 add { events.AddHandler (sendMailErrorEvent, value); }
124 remove { events.RemoveHandler (sendMailErrorEvent, value); }
128 #region Public Properties
131 public virtual int BorderPadding {
132 get { return ViewState.GetInt ("BorderPadding", 1); }
135 throw new ArgumentOutOfRangeException ();
136 ViewState ["BorderPadding"] = value;
142 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
143 public virtual string CancelButtonImageUrl {
144 get { return ViewState.GetString ("CancelButtonImageUrl", String.Empty); }
145 set { ViewState ["CancelButtonImageUrl"] = value; }
148 [DefaultValue (null)]
149 [PersistenceMode (PersistenceMode.InnerProperty)]
150 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
151 [NotifyParentProperty (true)]
152 public Style CancelButtonStyle {
154 if (_cancelButtonStyle == null) {
155 _cancelButtonStyle = new Style ();
156 if (IsTrackingViewState)
157 _cancelButtonStyle.TrackViewState ();
159 return _cancelButtonStyle;
164 public virtual string CancelButtonText {
165 get { return ViewState.GetString ("CancelButtonText", "Cancel"); }
166 set { ViewState ["CancelButtonText"] = value; }
169 [DefaultValue (ButtonType.Button)]
170 public virtual ButtonType CancelButtonType {
171 get { return ViewState ["CancelButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["CancelButtonType"]; }
172 set { ViewState ["CancelButtonType"] = value; }
178 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
179 public virtual string CancelDestinationPageUrl {
180 get { return ViewState.GetString ("CancelDestinationPageUrl", String.Empty); }
181 set { ViewState ["CancelDestinationPageUrl"] = value; }
186 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
187 public virtual string ChangePasswordButtonImageUrl {
188 get { return ViewState.GetString ("ChangePasswordButtonImageUrl", String.Empty); }
189 set { ViewState ["ChangePasswordButtonImageUrl"] = value; }
193 [PersistenceMode (PersistenceMode.InnerProperty)]
194 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
195 [NotifyParentProperty (true)]
196 public Style ChangePasswordButtonStyle {
198 if (_changePasswordButtonStyle == null) {
199 _changePasswordButtonStyle = new Style ();
200 if (IsTrackingViewState)
201 _changePasswordButtonStyle.TrackViewState ();
203 return _changePasswordButtonStyle;
208 public virtual string ChangePasswordButtonText {
209 get { return ViewState.GetString ("ChangePasswordButtonText", "Change Password"); }
210 set { ViewState ["ChangePasswordButtonText"] = value; }
213 [DefaultValue (ButtonType.Button)]
214 public virtual ButtonType ChangePasswordButtonType {
215 get { return ViewState ["ChangePasswordButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["ChangePasswordButtonType"]; }
216 set { ViewState ["ChangePasswordButtonType"] = value; }
220 public virtual string ChangePasswordFailureText {
221 get { return ViewState.GetString ("ChangePasswordFailureText", "Your attempt to change passwords was unsuccessful. Please try again."); }
222 set { ViewState ["ChangePasswordFailureText"] = value; }
226 [PersistenceMode (PersistenceMode.InnerProperty)]
227 [TemplateContainer (typeof (ChangePassword))]
228 public virtual ITemplate ChangePasswordTemplate {
229 get { return _changePasswordTemplate; }
230 set { _changePasswordTemplate = value; }
234 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
235 public Control ChangePasswordTemplateContainer {
237 if (_changePasswordTemplateContainer == null)
238 _changePasswordTemplateContainer = new ChangePasswordContainer (this);
239 return _changePasswordTemplateContainer;
244 public virtual string ChangePasswordTitleText {
245 get { return ViewState.GetString ("ChangePasswordTitleText", "Change Your Password"); }
246 set { ViewState ["ChangePasswordTitleText"] = value; }
249 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
253 public virtual string ConfirmNewPassword {
254 get { return _newPasswordConfirm != null ? _newPasswordConfirm : String.Empty; }
258 public virtual string ConfirmNewPasswordLabelText {
259 get { return ViewState.GetString ("ConfirmNewPasswordLabelText", "Confirm New Password:"); }
260 set { ViewState ["ConfirmNewPasswordLabelText"] = value; }
264 public virtual string ConfirmPasswordCompareErrorMessage {
265 get { return ViewState.GetString ("ConfirmPasswordCompareErrorMessage", "The Confirm New Password must match the New Password entry."); }
266 set { ViewState ["ConfirmPasswordCompareErrorMessage"] = value; }
270 public virtual string ConfirmPasswordRequiredErrorMessage {
271 get { return ViewState.GetString ("ConfirmPasswordRequiredErrorMessage", "Confirm New Password is required."); }
272 set { ViewState ["ConfirmPasswordRequiredErrorMessage"] = value; }
277 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
278 public virtual string ContinueButtonImageUrl {
279 get { return ViewState.GetString ("ContinueButtonImageUrl", String.Empty); }
280 set { ViewState ["ContinueButtonImageUrl"] = value; }
283 [DefaultValue (null)]
284 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
285 [NotifyParentProperty (true)]
286 [PersistenceMode (PersistenceMode.InnerProperty)]
287 public Style ContinueButtonStyle {
289 if (_continueButtonStyle == null) {
290 _continueButtonStyle = new Style ();
291 if (IsTrackingViewState)
292 _continueButtonStyle.TrackViewState ();
294 return _continueButtonStyle;
299 public virtual string ContinueButtonText {
300 get { return ViewState.GetString ("ContinueButtonText", "Continue"); }
301 set { ViewState ["ContinueButtonText"] = value; }
304 [DefaultValue (ButtonType.Button)]
305 public virtual ButtonType ContinueButtonType {
306 get { return ViewState ["ContinueButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["ContinueButtonType"]; }
307 set { ViewState ["ContinueButtonType"] = value; }
313 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
314 public virtual string ContinueDestinationPageUrl {
315 get { return ViewState.GetString ("ContinueDestinationPageUrl", String.Empty); }
316 set { ViewState ["ContinueDestinationPageUrl"] = value; }
321 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
322 public virtual string CreateUserIconUrl {
323 get { return ViewState.GetString ("CreateUserIconUrl", String.Empty); }
324 set { ViewState ["CreateUserIconUrl"] = value; }
329 public virtual string CreateUserText {
330 get { return ViewState.GetString ("CreateUserText", String.Empty); }
331 set { ViewState ["CreateUserText"] = value; }
336 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
337 public virtual string CreateUserUrl {
338 get { return ViewState.GetString ("CreateUserUrl", String.Empty); }
339 set { ViewState ["CreateUserUrl"] = value; }
342 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
346 public virtual string CurrentPassword {
347 get { return _currentPassword != null ? _currentPassword : String.Empty; }
350 [DefaultValue (false)]
351 public virtual bool DisplayUserName {
352 get { return ViewState.GetBool ("DisplayUserName", false); }
353 set { ViewState ["DisplayUserName"] = value; }
358 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
359 public virtual string EditProfileIconUrl {
360 get { return ViewState.GetString ("EditProfileIconUrl", String.Empty); }
361 set { ViewState ["EditProfileIconUrl"] = value; }
366 public virtual string EditProfileText {
367 get { return ViewState.GetString ("EditProfileText", String.Empty); }
368 set { ViewState ["EditProfileText"] = value; }
373 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
374 public virtual string EditProfileUrl {
375 get { return ViewState.GetString ("EditProfileUrl", String.Empty); }
376 set { ViewState ["EditProfileUrl"] = value; }
379 [DefaultValue (null)]
380 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
381 [NotifyParentProperty (true)]
382 [PersistenceMode (PersistenceMode.InnerProperty)]
383 public TableItemStyle FailureTextStyle {
385 if (_failureTextStyle == null) {
386 _failureTextStyle = new TableItemStyle ();
387 if (IsTrackingViewState)
388 _failureTextStyle.TrackViewState ();
390 return _failureTextStyle;
396 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
397 public virtual string HelpPageIconUrl {
398 get { return ViewState.GetString ("HelpPageIconUrl", String.Empty); }
399 set { ViewState ["HelpPageIconUrl"] = value; }
404 public virtual string HelpPageText {
405 get { return ViewState.GetString ("HelpPageText", String.Empty); }
406 set { ViewState ["HelpPageText"] = value; }
411 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
412 public virtual string HelpPageUrl {
413 get { return ViewState.GetString ("HelpPageUrl", String.Empty); }
414 set { ViewState ["HelpPageUrl"] = value; }
417 [DefaultValue (null)]
418 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
419 [NotifyParentProperty (true)]
420 [PersistenceMode (PersistenceMode.InnerProperty)]
421 public TableItemStyle HyperLinkStyle {
423 if (_hyperLinkStyle == null) {
424 _hyperLinkStyle = new TableItemStyle ();
425 if (IsTrackingViewState)
426 _hyperLinkStyle.TrackViewState ();
428 return _hyperLinkStyle;
434 public virtual string InstructionText {
435 get { return ViewState.GetString ("InstructionText", String.Empty); }
436 set { ViewState ["InstructionText"] = value; }
439 [DefaultValue (null)]
440 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
441 [NotifyParentProperty (true)]
442 [PersistenceMode (PersistenceMode.InnerProperty)]
443 public TableItemStyle InstructionTextStyle {
445 if (_instructionTextStyle == null) {
446 _instructionTextStyle = new TableItemStyle ();
447 if (IsTrackingViewState)
448 _instructionTextStyle.TrackViewState ();
450 return _instructionTextStyle;
454 [DefaultValue (null)]
455 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
456 [NotifyParentProperty (true)]
457 [PersistenceMode (PersistenceMode.InnerProperty)]
458 public TableItemStyle LabelStyle {
460 if (_labelStyle == null) {
461 _labelStyle = new TableItemStyle ();
462 if (IsTrackingViewState)
463 _labelStyle.TrackViewState ();
470 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
471 [NotifyParentProperty (true)]
472 [PersistenceMode (PersistenceMode.InnerProperty)]
473 public MailDefinition MailDefinition {
475 if (_mailDefinition == null) {
476 _mailDefinition = new MailDefinition ();
477 if (IsTrackingViewState)
478 ((IStateManager) _mailDefinition).TrackViewState ();
480 return _mailDefinition;
486 public virtual string MembershipProvider {
488 object o = ViewState ["MembershipProvider"];
489 return (o == null) ? String.Empty : (string) o;
494 ViewState.Remove ("MembershipProvider");
496 ViewState ["MembershipProvider"] = value;
504 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
506 public virtual string NewPassword {
507 get { return _newPassword != null ? _newPassword : String.Empty; }
511 public virtual string NewPasswordLabelText {
512 get { return ViewState.GetString ("NewPasswordLabelText", "New Password:"); }
513 set { ViewState ["NewPasswordLabelText"] = value; }
516 public virtual string NewPasswordRegularExpression {
517 get { return ViewState.GetString ("NewPasswordRegularExpression", String.Empty); }
518 set { ViewState ["NewPasswordRegularExpression"] = value; }
521 public virtual string NewPasswordRegularExpressionErrorMessage {
522 get { return ViewState.GetString ("NewPasswordRegularExpressionErrorMessage", String.Empty); }
523 set { ViewState ["NewPasswordRegularExpressionErrorMessage"] = value; }
527 public virtual string NewPasswordRequiredErrorMessage {
528 get { return ViewState.GetString ("NewPasswordRequiredErrorMessage", "New Password is required."); }
529 set { ViewState ["NewPasswordRequiredErrorMessage"] = value; }
532 [DefaultValue (null)]
533 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
534 [NotifyParentProperty (true)]
535 [PersistenceMode (PersistenceMode.InnerProperty)]
536 public TableItemStyle PasswordHintStyle {
538 if (_passwordHintStyle == null) {
539 _passwordHintStyle = new TableItemStyle ();
540 if (IsTrackingViewState)
541 _passwordHintStyle.TrackViewState ();
543 return _passwordHintStyle;
549 public virtual string PasswordHintText {
550 get { return ViewState.GetString ("PasswordHintText", String.Empty); }
551 set { ViewState ["PasswordHintText"] = value; }
555 public virtual string PasswordLabelText {
556 get { return ViewState.GetString ("PasswordLabelText", "Password:"); }
557 set { ViewState ["PasswordLabelText"] = value; }
562 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
563 public virtual string PasswordRecoveryIconUrl {
564 get { return ViewState.GetString ("PasswordRecoveryIconUrl", String.Empty); }
565 set { ViewState ["PasswordRecoveryIconUrl"] = value; }
570 public virtual string PasswordRecoveryText {
571 get { return ViewState.GetString ("PasswordRecoveryText", String.Empty); }
572 set { ViewState ["PasswordRecoveryText"] = value; }
577 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
578 public virtual string PasswordRecoveryUrl {
579 get { return ViewState.GetString ("PasswordRecoveryUrl", String.Empty); }
580 set { ViewState ["PasswordRecoveryUrl"] = value; }
584 public virtual string PasswordRequiredErrorMessage {
585 get { return ViewState.GetString ("PasswordRequiredErrorMessage", String.Empty); }
586 set { ViewState ["PasswordRequiredErrorMessage"] = value; }
588 // LAMESPEC: MSDN claims it's present in 3.5, but it's not
589 [DefaultValue (true)]
590 public virtual bool RenderOuterTable {
591 get { return renderOuterTable; }
592 set { renderOuterTable = value; }
596 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
598 public virtual string SuccessPageUrl {
599 get { return ViewState.GetString ("SuccessPageUrl", String.Empty); }
600 set { ViewState ["SuccessPageUrl"] = value; }
603 [PersistenceMode (PersistenceMode.InnerProperty)]
604 [TemplateContainer (typeof (ChangePassword))]
606 public virtual ITemplate SuccessTemplate {
607 get { return _successTemplate; }
608 set { _successTemplate = value; }
612 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
613 public Control SuccessTemplateContainer {
615 if (_successTemplateContainer == null)
616 _successTemplateContainer = new SuccessContainer (this);
617 return _successTemplateContainer;
623 public virtual string SuccessText {
624 get { return ViewState.GetString ("SuccessText", "Your password has been changed!"); }
625 set { ViewState ["SuccessText"] = value; }
628 [DefaultValue (null)]
629 [NotifyParentProperty (true)]
630 [PersistenceMode (PersistenceMode.InnerProperty)]
631 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
632 public TableItemStyle SuccessTextStyle {
634 if (_successTextStyle == null) {
635 _successTextStyle = new TableItemStyle ();
636 if (IsTrackingViewState)
637 _successTextStyle.TrackViewState ();
639 return _successTextStyle;
644 public virtual string SuccessTitleText {
645 get { return ViewState.GetString ("SuccessTitleText", "Change Password Complete"); }
646 set { ViewState ["SuccessTitleText"] = value; }
649 [DefaultValue (null)]
650 [NotifyParentProperty (true)]
651 [PersistenceMode (PersistenceMode.InnerProperty)]
652 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
653 public Style TextBoxStyle {
655 if (_textBoxStyle == null) {
656 _textBoxStyle = new Style ();
657 if (IsTrackingViewState)
658 _textBoxStyle.TrackViewState ();
660 return _textBoxStyle;
664 [DefaultValue (null)]
665 [NotifyParentProperty (true)]
666 [PersistenceMode (PersistenceMode.InnerProperty)]
667 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
668 public TableItemStyle TitleTextStyle {
670 if (_titleTextStyle == null) {
671 _titleTextStyle = new TableItemStyle ();
672 if (IsTrackingViewState)
673 _titleTextStyle.TrackViewState ();
675 return _titleTextStyle;
680 public virtual string UserName {
682 if (_username == null && HttpContext.Current.Request.IsAuthenticated)
683 _username = HttpContext.Current.User.Identity.Name;
685 return _username != null ? _username : String.Empty;
687 set { _username = value; }
691 public virtual string UserNameLabelText {
692 get { return ViewState.GetString ("UserNameLabelText", "User Name:"); }
693 set { ViewState ["UserNameLabelText"] = value; }
697 public virtual string UserNameRequiredErrorMessage {
698 get { return ViewState.GetString ("UserNameRequiredErrorMessage", "User Name is required."); }
699 set { ViewState ["UserNameRequiredErrorMessage"] = value; }
702 [DefaultValue (null)]
703 [NotifyParentProperty (true)]
704 [PersistenceMode (PersistenceMode.InnerProperty)]
705 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
706 public Style ValidatorTextStyle {
708 if (_validatorTextStyle == null) {
709 _validatorTextStyle = new Style ();
710 if (IsTrackingViewState)
711 _validatorTextStyle.TrackViewState ();
713 return _validatorTextStyle;
719 #region Protected Methods
721 protected internal override void CreateChildControls ()
725 ITemplate cpTemplate = ChangePasswordTemplate;
726 if (cpTemplate == null)
727 cpTemplate = new ChangePasswordDeafultTemplate (this);
728 ((ChangePasswordContainer) ChangePasswordTemplateContainer).InstantiateTemplate (cpTemplate);
730 ITemplate sTemplate = SuccessTemplate;
731 if (sTemplate == null)
732 sTemplate = new SuccessDefaultTemplate (this);
733 ((SuccessContainer) SuccessTemplateContainer).InstantiateTemplate (sTemplate);
735 Controls.AddAt (0, ChangePasswordTemplateContainer);
736 Controls.AddAt (1, SuccessTemplateContainer);
738 IEditableTextControl editable;
740 ChangePasswordContainer container = (ChangePasswordContainer) ChangePasswordTemplateContainer;
741 if (DisplayUserName) {
742 editable = container.UserNameTextBox;
743 if (editable != null)
744 editable.TextChanged += new EventHandler (UserName_TextChanged);
747 editable = container.CurrentPasswordTextBox;
748 if (editable != null)
749 editable.TextChanged += new EventHandler (CurrentPassword_TextChanged);
751 editable = container.NewPasswordTextBox;
752 if (editable != null)
753 editable.TextChanged += new EventHandler (NewPassword_TextChanged);
755 editable = container.ConfirmNewPasswordTextBox;
756 if (editable != null)
757 editable.TextChanged += new EventHandler (NewPasswordConfirm_TextChanged);
760 protected internal override void Render (HtmlTextWriter writer)
762 VerifyInlinePropertiesNotSet ();
763 for (int i = 0; i < Controls.Count; i++)
764 if (Controls [i].Visible)
765 Controls [i].Render (writer);
770 #region Private Methods
772 [MonoTODO ("Not implemented")]
773 protected override void SetDesignModeState (IDictionary data)
775 throw new NotImplementedException ();
778 void InitMemberShipProvider ()
780 string mp = MembershipProvider;
781 _provider = (mp.Length == 0) ? Membership.Provider : Membership.Providers [mp];
782 if (_provider == null)
783 throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
786 void ProcessChangePasswordEvent (CommandEventArgs args)
791 LoginCancelEventArgs loginCancelEventArgs = new LoginCancelEventArgs ();
792 OnChangingPassword (loginCancelEventArgs);
793 if (loginCancelEventArgs.Cancel)
798 res = MembershipProviderInternal.ChangePassword (UserName, CurrentPassword, NewPassword);
803 OnChangedPassword (args);
804 _showContinue = true;
806 if (_mailDefinition != null)
807 SendMail (UserName, NewPassword);
809 OnChangePasswordError (EventArgs.Empty);
810 string lastError = string.Format (
811 "Password incorrect or New Password invalid. New Password length minimum: {0}. Non-alphanumeric characters required: {1}.",
812 MembershipProviderInternal.MinRequiredPasswordLength,
813 MembershipProviderInternal.MinRequiredNonAlphanumericCharacters);
815 ChangePasswordContainer container = (ChangePasswordContainer) ChangePasswordTemplateContainer;
816 container.FailureTextLiteral.Text = lastError;
817 _showContinue = false;
823 void ProcessCancelEvent (CommandEventArgs args)
825 OnCancelButtonClick (args);
827 if (ContinueDestinationPageUrl.Length > 0)
828 Context.Response.Redirect (ContinueDestinationPageUrl);
833 void ProcessContinueEvent (CommandEventArgs args)
835 OnContinueButtonClick (args);
837 if (ContinueDestinationPageUrl.Length > 0)
838 Context.Response.Redirect (ContinueDestinationPageUrl);
843 void SendMail (string username, string password)
845 MembershipUser user = MembershipProviderInternal.GetUser (UserName, false);
849 ListDictionary dictionary = new ListDictionary ();
850 dictionary.Add ("<%USERNAME%>", username);
851 dictionary.Add ("<%PASSWORD%>", password);
853 MailMessage message = MailDefinition.CreateMailMessage (user.Email, dictionary, this);
855 MailMessageEventArgs args = new MailMessageEventArgs (message);
856 OnSendingMail (args);
858 SmtpClient smtpClient = new SmtpClient ();
860 smtpClient.Send (message);
861 } catch (Exception e) {
862 SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e);
863 OnSendMailError (mailArgs);
864 if (!mailArgs.Handled)
873 protected override HtmlTextWriterTag TagKey {
874 get { return HtmlTextWriterTag.Table; }
877 internal virtual MembershipProvider MembershipProviderInternal {
879 if (_provider == null)
880 InitMemberShipProvider ();
888 #region View and Control State
890 protected internal override void LoadControlState (object savedState)
892 if (savedState == null)
894 object [] state = (object []) savedState;
895 base.LoadControlState (state [0]);
897 _showContinue = (bool) state [1];
898 _username = (string) state [2];
901 protected internal override object SaveControlState ()
903 object state = base.SaveControlState ();
904 return new object [] { state, _showContinue, _username };
907 protected override void LoadViewState (object savedState)
909 if (savedState == null)
912 object [] states = (object []) savedState;
913 base.LoadViewState (states [0]);
915 if (states [1] != null)
916 CancelButtonStyle.LoadViewState (states [1]);
917 if (states [2] != null)
918 ChangePasswordButtonStyle.LoadViewState (states [2]);
919 if (states [3] != null)
920 ContinueButtonStyle.LoadViewState (states [3]);
922 if (states [4] != null)
923 FailureTextStyle.LoadViewState (states [4]);
924 if (states [5] != null)
925 HyperLinkStyle.LoadViewState (states [5]);
926 if (states [6] != null)
927 InstructionTextStyle.LoadViewState (states [6]);
929 if (states [7] != null)
930 LabelStyle.LoadViewState (states [7]);
931 if (states [8] != null)
932 PasswordHintStyle.LoadViewState (states [8]);
933 if (states [9] != null)
934 SuccessTextStyle.LoadViewState (states [9]);
936 if (states [10] != null)
937 TextBoxStyle.LoadViewState (states [10]);
938 if (states [11] != null)
939 TitleTextStyle.LoadViewState (states [11]);
940 if (states [12] != null)
941 ValidatorTextStyle.LoadViewState (states [12]);
943 if (states [13] != null)
944 ((IStateManager) MailDefinition).LoadViewState (states [13]);
947 protected override object SaveViewState ()
949 object [] states = new object [14];
950 states [0] = base.SaveViewState ();
952 if (_cancelButtonStyle != null)
953 states [1] = _cancelButtonStyle.SaveViewState ();
954 if (_changePasswordButtonStyle != null)
955 states [2] = _changePasswordButtonStyle.SaveViewState ();
956 if (_continueButtonStyle != null)
957 states [3] = _continueButtonStyle.SaveViewState ();
959 if (_failureTextStyle != null)
960 states [4] = _failureTextStyle.SaveViewState ();
961 if (_hyperLinkStyle != null)
962 states [5] = _hyperLinkStyle.SaveViewState ();
963 if (_instructionTextStyle != null)
964 states [6] = _instructionTextStyle.SaveViewState ();
966 if (_labelStyle != null)
967 states [7] = _labelStyle.SaveViewState ();
968 if (_passwordHintStyle != null)
969 states [8] = _passwordHintStyle.SaveViewState ();
970 if (_successTextStyle != null)
971 states [9] = _successTextStyle.SaveViewState ();
973 if (_textBoxStyle != null)
974 states [10] = _textBoxStyle.SaveViewState ();
975 if (_titleTextStyle != null)
976 states [11] = _titleTextStyle.SaveViewState ();
977 if (_validatorTextStyle != null)
978 states [12] = _validatorTextStyle.SaveViewState ();
980 if (_mailDefinition != null)
981 states [13] = ((IStateManager) _mailDefinition).SaveViewState ();
983 for (int i = 0; i < states.Length; i++) {
984 if (states [i] != null)
990 protected override void TrackViewState ()
992 base.TrackViewState ();
994 if (_cancelButtonStyle != null)
995 _cancelButtonStyle.TrackViewState ();
996 if (_changePasswordButtonStyle != null)
997 _changePasswordButtonStyle.TrackViewState ();
998 if (_continueButtonStyle != null)
999 _continueButtonStyle.TrackViewState ();
1001 if (_failureTextStyle != null)
1002 _failureTextStyle.TrackViewState ();
1003 if (_hyperLinkStyle != null)
1004 _hyperLinkStyle.TrackViewState ();
1005 if (_instructionTextStyle != null)
1006 _instructionTextStyle.TrackViewState ();
1008 if (_labelStyle != null)
1009 _labelStyle.TrackViewState ();
1010 if (_passwordHintStyle != null)
1011 _passwordHintStyle.TrackViewState ();
1012 if (_successTextStyle != null)
1013 _successTextStyle.TrackViewState ();
1015 if (_textBoxStyle != null)
1016 _textBoxStyle.TrackViewState ();
1017 if (_titleTextStyle != null)
1018 _titleTextStyle.TrackViewState ();
1019 if (_validatorTextStyle != null)
1020 _validatorTextStyle.TrackViewState ();
1022 if (_mailDefinition != null)
1023 ((IStateManager) _mailDefinition).TrackViewState ();
1028 #region Event Handlers
1030 protected override bool OnBubbleEvent (object source, EventArgs e)
1032 CommandEventArgs args = e as CommandEventArgs;
1034 if (args.CommandName == ChangePasswordButtonCommandName) {
1035 ProcessChangePasswordEvent (args);
1039 if (args.CommandName == CancelButtonCommandName) {
1040 ProcessCancelEvent (args);
1044 if (args.CommandName == ContinueButtonCommandName) {
1045 ProcessContinueEvent (args);
1049 return base.OnBubbleEvent (source, e);
1052 protected virtual void OnCancelButtonClick (EventArgs e)
1054 EventHandler eh = events [cancelButtonClickEvent] as EventHandler;
1059 protected virtual void OnChangedPassword (EventArgs e)
1061 EventHandler eh = events [changedPasswordEvent] as EventHandler;
1066 protected virtual void OnChangePasswordError (EventArgs e)
1068 EventHandler eh = events [changePasswordErrorEvent] as EventHandler;
1073 protected virtual void OnChangingPassword (LoginCancelEventArgs e)
1075 LoginCancelEventHandler eh = events [changingPasswordEvent] as LoginCancelEventHandler;
1080 protected virtual void OnContinueButtonClick (EventArgs e)
1082 EventHandler eh = events [continueButtonClickEvent] as EventHandler;
1087 protected internal override void OnInit (EventArgs e)
1089 Page.RegisterRequiresControlState (this);
1093 protected internal override void OnPreRender (EventArgs e)
1095 ChangePasswordTemplateContainer.Visible = !_showContinue;
1096 SuccessTemplateContainer.Visible = _showContinue;
1097 base.OnPreRender (e);
1100 protected virtual void OnSendingMail (MailMessageEventArgs e)
1102 MailMessageEventHandler eh = events [sendingMailEvent] as MailMessageEventHandler;
1107 protected virtual void OnSendMailError (SendMailErrorEventArgs e)
1109 SendMailErrorEventHandler eh = events [sendMailErrorEvent] as SendMailErrorEventHandler;
1114 void UserName_TextChanged (object sender, EventArgs e)
1116 UserName = ((ITextControl) sender).Text;
1119 void CurrentPassword_TextChanged (object sender, EventArgs e)
1121 _currentPassword = ((ITextControl) sender).Text;
1124 void NewPassword_TextChanged (object sender, EventArgs e)
1126 _newPassword = ((ITextControl) sender).Text;
1129 void NewPasswordConfirm_TextChanged (object sender, EventArgs e)
1131 _newPasswordConfirm = ((ITextControl) sender).Text;
1136 class BaseChangePasswordContainer : Control, INamingContainer, INonBindingContainer
1138 protected readonly ChangePassword _owner = null;
1139 bool renderOuterTable;
1140 Table _table = null;
1141 TableCell _containerCell = null;
1143 public BaseChangePasswordContainer (ChangePassword owner)
1146 throw new ArgumentNullException ("owner");
1149 renderOuterTable = _owner.RenderOuterTable;
1151 if (renderOuterTable)
1155 public void InstantiateTemplate (ITemplate template)
1157 if (!_owner.RenderOuterTable)
1158 template.InstantiateIn (this);
1160 template.InstantiateIn (_containerCell);
1165 _table = new Table ();
1166 string id = _owner.ID;
1167 if (!String.IsNullOrEmpty (id))
1168 _table.Attributes.Add ("id", _owner.ID);
1170 _table.CellSpacing = 0;
1171 _table.CellPadding = _owner.BorderPadding;
1173 _containerCell = new TableCell ();
1175 TableRow row = new TableRow ();
1176 row.Cells.Add (_containerCell);
1177 _table.Rows.Add (row);
1179 Controls.AddAt (0, _table);
1182 protected internal override void OnPreRender (EventArgs e)
1185 _table.ApplyStyle (_owner.ControlStyle);
1186 base.OnPreRender (e);
1189 protected override void EnsureChildControls ()
1191 base.EnsureChildControls ();
1193 // it's the owner who adds controls, not us
1195 _owner.EnsureChildControls ();
1199 sealed class ChangePasswordContainer : BaseChangePasswordContainer
1201 public ChangePasswordContainer (ChangePassword owner) : base (owner)
1203 ID = "ChangePasswordContainerID";
1206 // Requried controls
1207 public IEditableTextControl UserNameTextBox {
1209 Control c = FindControl ("UserName");
1211 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID UserName for the username, this is required if DisplayUserName=true.");
1212 return c as IEditableTextControl;
1216 public IEditableTextControl CurrentPasswordTextBox {
1218 Control c = FindControl ("CurrentPassword");
1220 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID CurrentPassword for the current password.");
1221 return c as IEditableTextControl;
1225 public IEditableTextControl NewPasswordTextBox {
1227 Control c = FindControl ("NewPassword");
1229 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID NewPassword for the new password.");
1230 return c as IEditableTextControl;
1234 // Optional controls
1235 public IEditableTextControl ConfirmNewPasswordTextBox {
1236 get { return FindControl ("ConfirmNewPassword") as IEditableTextControl; }
1239 public Control CancelButton {
1240 get { return FindControl ("Cancel"); }
1243 public Control ChangePasswordButton {
1244 get { return FindControl ("ChangePassword"); }
1247 public ITextControl FailureTextLiteral {
1248 get { return FindControl ("FailureText") as ITextControl; }
1252 sealed class ChangePasswordDeafultTemplate : ITemplate
1254 readonly ChangePassword _owner = null;
1256 internal ChangePasswordDeafultTemplate (ChangePassword cPassword)
1261 TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1)
1263 TableRow row = new TableRow ();
1264 TableCell cell0 = new TableCell ();
1265 TableCell cell1 = new TableCell ();
1267 cell0.Controls.Add (c0);
1268 row.Controls.Add (cell0);
1270 if ((c1 != null) && (c2 != null)) {
1271 cell1.Controls.Add (c1);
1272 cell1.Controls.Add (c2);
1273 cell0.HorizontalAlign = HorizontalAlign.Right;
1276 cell0.ApplyStyle (s0);
1278 cell1.ApplyStyle (s1);
1280 row.Controls.Add (cell1);
1282 cell0.ColumnSpan = 2;
1283 cell0.HorizontalAlign = HorizontalAlign.Center;
1285 cell0.ApplyStyle (s0);
1290 bool AddLink (string pageUrl, string linkText, string linkIcon, WebControl container)
1293 if (linkIcon.Length > 0) {
1294 Image img = new Image ();
1295 img.ImageUrl = linkIcon;
1296 container.Controls.Add (img);
1299 if (linkText.Length > 0) {
1300 HyperLink link = new HyperLink ();
1301 link.NavigateUrl = pageUrl;
1302 link.Text = linkText;
1303 link.ControlStyle.CopyTextStylesFrom (container.ControlStyle);
1304 container.Controls.Add (link);
1310 public void InstantiateIn (Control container)
1312 Table table = new Table ();
1313 table.CellPadding = 0;
1314 Style ownerStyle = _owner.ControlStyle;
1315 Style tableStyle = table.ControlStyle;
1316 FontInfo ownerFont = ownerStyle.Font;
1318 tableStyle.Font.CopyFrom (ownerFont);
1319 ownerFont.ClearDefaults ();
1321 Color ownerForeColor = ownerStyle.ForeColor;
1322 if (ownerForeColor != Color.Empty) {
1323 tableStyle.ForeColor = ownerForeColor;
1324 ownerStyle.RemoveBit ((int)global::System.Web.UI.WebControls.Style.Styles.ForeColor);
1327 table.Controls.Add (
1328 CreateRow (new LiteralControl (_owner.ChangePasswordTitleText),
1329 null, null, _owner.TitleTextStyle, null));
1332 if (_owner.InstructionText.Length > 0) {
1333 table.Controls.Add (
1334 CreateRow (new LiteralControl (_owner.InstructionText),
1335 null, null, _owner.InstructionTextStyle, null));
1339 if (_owner.DisplayUserName) {
1340 TextBox UserName = new TextBox ();
1341 UserName.ID = "UserName";
1342 UserName.Text = _owner.UserName;
1343 UserName.ApplyStyle (_owner.TextBoxStyle);
1345 Label UserNameLabel = new Label ();
1346 UserNameLabel.ID = "UserNameLabel";
1347 UserNameLabel.AssociatedControlID = "UserName";
1348 UserNameLabel.Text = _owner.UserNameLabelText;
1350 RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
1351 UserNameRequired.ID = "UserNameRequired";
1352 UserNameRequired.ControlToValidate = "UserName";
1353 UserNameRequired.ErrorMessage = _owner.UserNameRequiredErrorMessage;
1354 UserNameRequired.ToolTip = _owner.UserNameRequiredErrorMessage;
1355 UserNameRequired.Text = "*";
1356 UserNameRequired.ValidationGroup = _owner.ID;
1357 UserNameRequired.ApplyStyle (_owner.ValidatorTextStyle);
1359 table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _owner.LabelStyle, null));
1363 TextBox CurrentPassword = new TextBox ();
1364 CurrentPassword.ID = "CurrentPassword";
1365 CurrentPassword.TextMode = TextBoxMode.Password;
1366 CurrentPassword.ApplyStyle (_owner.TextBoxStyle);
1368 Label CurrentPasswordLabel = new Label ();
1369 CurrentPasswordLabel.ID = "CurrentPasswordLabel";
1370 CurrentPasswordLabel.AssociatedControlID = "CurrentPasswordLabel";
1371 CurrentPasswordLabel.Text = _owner.PasswordLabelText;
1373 RequiredFieldValidator CurrentPasswordRequired = new RequiredFieldValidator ();
1374 CurrentPasswordRequired.ID = "CurrentPasswordRequired";
1375 CurrentPasswordRequired.ControlToValidate = "CurrentPassword";
1376 CurrentPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1377 CurrentPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1378 CurrentPasswordRequired.Text = "*";
1379 CurrentPasswordRequired.ValidationGroup = _owner.ID;
1380 CurrentPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1382 table.Controls.Add (CreateRow (CurrentPasswordLabel, CurrentPassword, CurrentPasswordRequired, _owner.LabelStyle, null));
1385 TextBox NewPassword = new TextBox ();
1386 NewPassword.ID = "NewPassword";
1387 NewPassword.TextMode = TextBoxMode.Password;
1388 NewPassword.ApplyStyle (_owner.TextBoxStyle);
1390 Label NewPasswordLabel = new Label ();
1391 NewPasswordLabel.ID = "NewPasswordLabel";
1392 NewPasswordLabel.AssociatedControlID = "NewPassword";
1393 NewPasswordLabel.Text = _owner.NewPasswordLabelText;
1395 RequiredFieldValidator NewPasswordRequired = new RequiredFieldValidator ();
1396 NewPasswordRequired.ID = "NewPasswordRequired";
1397 NewPasswordRequired.ControlToValidate = "NewPassword";
1398 NewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1399 NewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1400 NewPasswordRequired.Text = "*";
1401 NewPasswordRequired.ValidationGroup = _owner.ID;
1402 NewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1404 table.Controls.Add (CreateRow (NewPasswordLabel, NewPassword, NewPasswordRequired, _owner.LabelStyle, null));
1407 if (_owner.PasswordHintText.Length > 0) {
1408 table.Controls.Add (
1409 CreateRow (new LiteralControl (String.Empty),
1410 new LiteralControl (_owner.PasswordHintText),
1411 new LiteralControl (String.Empty),
1412 null, _owner.PasswordHintStyle));
1416 TextBox ConfirmNewPassword = new TextBox ();
1417 ConfirmNewPassword.ID = "ConfirmNewPassword";
1418 ConfirmNewPassword.TextMode = TextBoxMode.Password;
1419 ConfirmNewPassword.ApplyStyle (_owner.TextBoxStyle);
1421 Label ConfirmNewPasswordLabel = new Label ();
1422 ConfirmNewPasswordLabel.ID = "ConfirmNewPasswordLabel";
1423 ConfirmNewPasswordLabel.AssociatedControlID = "ConfirmNewPasswordLabel";
1424 ConfirmNewPasswordLabel.Text = _owner.ConfirmNewPasswordLabelText;
1426 RequiredFieldValidator ConfirmNewPasswordRequired = new RequiredFieldValidator ();
1427 ConfirmNewPasswordRequired.ID = "ConfirmNewPasswordRequired";
1428 ConfirmNewPasswordRequired.ControlToValidate = "ConfirmNewPassword";
1429 ConfirmNewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1430 ConfirmNewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1431 ConfirmNewPasswordRequired.Text = "*";
1432 ConfirmNewPasswordRequired.ValidationGroup = _owner.ID;
1433 ConfirmNewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1435 table.Controls.Add (CreateRow (ConfirmNewPasswordLabel, ConfirmNewPassword, ConfirmNewPasswordRequired, _owner.LabelStyle, null));
1438 CompareValidator NewPasswordCompare = new CompareValidator ();
1439 NewPasswordCompare.ID = "NewPasswordCompare";
1440 NewPasswordCompare.ControlToCompare = "NewPassword";
1441 NewPasswordCompare.ControlToValidate = "ConfirmNewPassword";
1442 NewPasswordCompare.Display = ValidatorDisplay.Dynamic;
1443 NewPasswordCompare.ErrorMessage = _owner.ConfirmPasswordCompareErrorMessage;
1444 NewPasswordCompare.ValidationGroup = _owner.ID;
1446 table.Controls.Add (CreateRow (NewPasswordCompare, null, null, null, null));
1449 Literal FailureTextLiteral = new Literal ();
1450 FailureTextLiteral.ID = "FailureText";
1451 FailureTextLiteral.EnableViewState = false;
1453 if (_owner.FailureTextStyle.ForeColor.IsEmpty)
1454 _owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
1456 table.Controls.Add (CreateRow (FailureTextLiteral, null, null, _owner.FailureTextStyle, null));
1459 WebControl ChangePasswordButton = null;
1460 switch (_owner.ChangePasswordButtonType) {
1461 case ButtonType.Button:
1462 ChangePasswordButton = new Button ();
1464 case ButtonType.Image:
1465 ChangePasswordButton = new ImageButton ();
1467 case ButtonType.Link:
1468 ChangePasswordButton = new LinkButton ();
1472 ChangePasswordButton.ID = "ChangePasswordPushButton";
1473 ChangePasswordButton.ApplyStyle (_owner.ChangePasswordButtonStyle);
1474 ((IButtonControl) ChangePasswordButton).CommandName = ChangePassword.ChangePasswordButtonCommandName;
1475 ((IButtonControl) ChangePasswordButton).Text = _owner.ChangePasswordButtonText;
1476 ((IButtonControl) ChangePasswordButton).ValidationGroup = _owner.ID;
1478 WebControl CancelButton = null;
1479 switch (_owner.CancelButtonType) {
1480 case ButtonType.Button:
1481 CancelButton = new Button ();
1483 case ButtonType.Image:
1484 CancelButton = new ImageButton ();
1486 case ButtonType.Link:
1487 CancelButton = new LinkButton ();
1491 CancelButton.ID = "CancelPushButton";
1492 CancelButton.ApplyStyle (_owner.CancelButtonStyle);
1493 ((IButtonControl) CancelButton).CommandName = ChangePassword.CancelButtonCommandName;
1494 ((IButtonControl) CancelButton).Text = _owner.CancelButtonText;
1495 ((IButtonControl) CancelButton).CausesValidation = false;
1497 table.Controls.Add (CreateRow (ChangePasswordButton, CancelButton, new LiteralControl (String.Empty), null, null));
1500 TableRow linksRow = new TableRow ();
1501 TableCell linksCell = new TableCell ();
1502 linksCell.ColumnSpan = 2;
1503 linksCell.ControlStyle.CopyFrom (_owner.HyperLinkStyle);
1505 linksRow.Cells.Add (linksCell);
1507 if (AddLink (_owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, linksCell))
1508 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1510 if (AddLink (_owner.CreateUserUrl, _owner.CreateUserText, _owner.CreateUserIconUrl, linksCell))
1511 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1513 if (AddLink (_owner.PasswordRecoveryUrl, _owner.PasswordRecoveryText, _owner.PasswordRecoveryIconUrl, linksCell))
1514 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1516 AddLink (_owner.EditProfileUrl, _owner.EditProfileText, _owner.EditProfileIconUrl, linksCell);
1518 table.Controls.Add (linksRow);
1520 container.Controls.Add (table);
1524 sealed class SuccessDefaultTemplate : ITemplate
1526 readonly ChangePassword _cPassword = null;
1528 internal SuccessDefaultTemplate (ChangePassword cPassword)
1530 _cPassword = cPassword;
1533 TableRow CreateRow (Control c0, Style s0, HorizontalAlign align)
1535 TableRow row = new TableRow ();
1536 TableCell cell0 = new TableCell ();
1538 cell0.Controls.Add (c0);
1539 cell0.HorizontalAlign = align;
1541 cell0.ApplyStyle (s0);
1543 row.Controls.Add (cell0);
1547 public void InstantiateIn (Control container)
1549 Table table = new Table ();
1550 table.ControlStyle.Width = Unit.Percentage (100);
1551 table.ControlStyle.Height = Unit.Percentage (100);
1554 table.Controls.Add (
1555 CreateRow (new LiteralControl (_cPassword.SuccessTitleText), _cPassword.TitleTextStyle, HorizontalAlign.Center));
1558 table.Controls.Add (
1559 CreateRow (new LiteralControl (_cPassword.SuccessText), _cPassword.SuccessTextStyle, HorizontalAlign.Center));
1562 WebControl ContinueButton = null;
1563 switch (_cPassword.ChangePasswordButtonType) {
1564 case ButtonType.Button:
1565 ContinueButton = new Button ();
1567 case ButtonType.Image:
1568 ContinueButton = new ImageButton ();
1570 case ButtonType.Link:
1571 ContinueButton = new LinkButton ();
1575 ContinueButton.ID = "ContinuePushButton";
1576 ContinueButton.ApplyStyle (_cPassword.ContinueButtonStyle);
1577 ((IButtonControl) ContinueButton).CommandName = ChangePassword.ContinueButtonCommandName;
1578 ((IButtonControl) ContinueButton).Text = _cPassword.ContinueButtonText;
1579 ((IButtonControl) ContinueButton).CausesValidation = false;
1581 table.Controls.Add (
1582 CreateRow (ContinueButton, null, HorizontalAlign.Right));
1584 container.Controls.Add (table);
1588 sealed class SuccessContainer : BaseChangePasswordContainer
1590 public SuccessContainer (ChangePassword owner) : base (owner)
1592 ID = "SuccessContainerID";
1595 public Control ChangePasswordButton
1597 get { return FindControl ("Continue"); }