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
50 static readonly object cancelButtonClickEvent = new object ();
51 static readonly object changedPasswordEvent = new object ();
52 static readonly object changePasswordErrorEvent = new object ();
53 static readonly object changingPasswordEvent = new object ();
54 static readonly object continueButtonClickEvent = new object ();
55 static readonly object sendingMailEvent = new object ();
56 static readonly object sendMailErrorEvent = new object ();
58 public static readonly string CancelButtonCommandName = "Cancel";
59 public static readonly string ChangePasswordButtonCommandName = "ChangePassword";
60 public static readonly string ContinueButtonCommandName = "Continue";
62 bool renderOuterTable = true;
64 Style _cancelButtonStyle = null;
65 Style _changePasswordButtonStyle = null;
66 Style _continueButtonStyle = null;
67 TableItemStyle _failureTextStyle = null;
68 TableItemStyle _hyperLinkStyle = null;
69 TableItemStyle _instructionTextStyle = null;
70 TableItemStyle _labelStyle = null;
71 TableItemStyle _passwordHintStyle = null;
72 TableItemStyle _successTextStyle = null;
73 Style _textBoxStyle = null;
74 TableItemStyle _titleTextStyle = null;
75 Style _validatorTextStyle = null;
77 MailDefinition _mailDefinition = null;
78 MembershipProvider _provider = null;
80 ITemplate _changePasswordTemplate = null;
81 ITemplate _successTemplate = null;
83 Control _changePasswordTemplateContainer = null;
84 Control _successTemplateContainer = null;
86 string _username = null;
87 string _currentPassword = null;
88 string _newPassword = null;
89 string _newPasswordConfirm = null;
91 bool _showContinue = false;
93 EventHandlerList events = new EventHandlerList ();
96 public event EventHandler CancelButtonClick {
97 add { events.AddHandler (cancelButtonClickEvent, value); }
98 remove { events.RemoveHandler (cancelButtonClickEvent, value); }
101 public event EventHandler ChangedPassword {
102 add { events.AddHandler (changedPasswordEvent, value); }
103 remove { events.RemoveHandler (changedPasswordEvent, value); }
106 public event EventHandler ChangePasswordError {
107 add { events.AddHandler (changePasswordErrorEvent, value); }
108 remove { events.RemoveHandler (changePasswordErrorEvent, value); }
111 public event LoginCancelEventHandler ChangingPassword {
112 add { events.AddHandler (changingPasswordEvent, value); }
113 remove { events.RemoveHandler (changingPasswordEvent, value); }
116 public event EventHandler ContinueButtonClick {
117 add { events.AddHandler (continueButtonClickEvent, value); }
118 remove { events.RemoveHandler (continueButtonClickEvent, value); }
121 public event MailMessageEventHandler SendingMail {
122 add { events.AddHandler (sendingMailEvent, value); }
123 remove { events.RemoveHandler (sendingMailEvent, value); }
126 public event SendMailErrorEventHandler SendMailError {
127 add { events.AddHandler (sendMailErrorEvent, value); }
128 remove { events.RemoveHandler (sendMailErrorEvent, value); }
132 #region Public Properties
135 public virtual int BorderPadding {
136 get { return ViewState.GetInt ("BorderPadding", 1); }
139 throw new ArgumentOutOfRangeException ();
140 ViewState ["BorderPadding"] = value;
146 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
147 public virtual string CancelButtonImageUrl {
148 get { return ViewState.GetString ("CancelButtonImageUrl", String.Empty); }
149 set { ViewState ["CancelButtonImageUrl"] = value; }
152 [DefaultValue (null)]
153 [PersistenceMode (PersistenceMode.InnerProperty)]
154 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
155 [NotifyParentProperty (true)]
156 public Style CancelButtonStyle {
158 if (_cancelButtonStyle == null) {
159 _cancelButtonStyle = new Style ();
160 if (IsTrackingViewState)
161 _cancelButtonStyle.TrackViewState ();
163 return _cancelButtonStyle;
168 public virtual string CancelButtonText {
169 get { return ViewState.GetString ("CancelButtonText", "Cancel"); }
170 set { ViewState ["CancelButtonText"] = value; }
173 [DefaultValue (ButtonType.Button)]
174 public virtual ButtonType CancelButtonType {
175 get { return ViewState ["CancelButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["CancelButtonType"]; }
176 set { ViewState ["CancelButtonType"] = value; }
182 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
183 public virtual string CancelDestinationPageUrl {
184 get { return ViewState.GetString ("CancelDestinationPageUrl", String.Empty); }
185 set { ViewState ["CancelDestinationPageUrl"] = value; }
190 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
191 public virtual string ChangePasswordButtonImageUrl {
192 get { return ViewState.GetString ("ChangePasswordButtonImageUrl", String.Empty); }
193 set { ViewState ["ChangePasswordButtonImageUrl"] = value; }
197 [PersistenceMode (PersistenceMode.InnerProperty)]
198 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
199 [NotifyParentProperty (true)]
200 public Style ChangePasswordButtonStyle {
202 if (_changePasswordButtonStyle == null) {
203 _changePasswordButtonStyle = new Style ();
204 if (IsTrackingViewState)
205 _changePasswordButtonStyle.TrackViewState ();
207 return _changePasswordButtonStyle;
212 public virtual string ChangePasswordButtonText {
213 get { return ViewState.GetString ("ChangePasswordButtonText", "Change Password"); }
214 set { ViewState ["ChangePasswordButtonText"] = value; }
217 [DefaultValue (ButtonType.Button)]
218 public virtual ButtonType ChangePasswordButtonType {
219 get { return ViewState ["ChangePasswordButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["ChangePasswordButtonType"]; }
220 set { ViewState ["ChangePasswordButtonType"] = value; }
224 public virtual string ChangePasswordFailureText {
225 get { return ViewState.GetString ("ChangePasswordFailureText", "Your attempt to change passwords was unsuccessful. Please try again."); }
226 set { ViewState ["ChangePasswordFailureText"] = value; }
230 [PersistenceMode (PersistenceMode.InnerProperty)]
231 [TemplateContainer (typeof (ChangePassword))]
232 public virtual ITemplate ChangePasswordTemplate {
233 get { return _changePasswordTemplate; }
234 set { _changePasswordTemplate = value; }
238 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
239 public Control ChangePasswordTemplateContainer {
241 if (_changePasswordTemplateContainer == null)
242 _changePasswordTemplateContainer = new ChangePasswordContainer (this);
243 return _changePasswordTemplateContainer;
248 public virtual string ChangePasswordTitleText {
249 get { return ViewState.GetString ("ChangePasswordTitleText", "Change Your Password"); }
250 set { ViewState ["ChangePasswordTitleText"] = value; }
253 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
257 public virtual string ConfirmNewPassword {
258 get { return _newPasswordConfirm != null ? _newPasswordConfirm : String.Empty; }
262 public virtual string ConfirmNewPasswordLabelText {
263 get { return ViewState.GetString ("ConfirmNewPasswordLabelText", "Confirm New Password:"); }
264 set { ViewState ["ConfirmNewPasswordLabelText"] = value; }
268 public virtual string ConfirmPasswordCompareErrorMessage {
269 get { return ViewState.GetString ("ConfirmPasswordCompareErrorMessage", "The Confirm New Password must match the New Password entry."); }
270 set { ViewState ["ConfirmPasswordCompareErrorMessage"] = value; }
274 public virtual string ConfirmPasswordRequiredErrorMessage {
275 get { return ViewState.GetString ("ConfirmPasswordRequiredErrorMessage", "Confirm New Password is required."); }
276 set { ViewState ["ConfirmPasswordRequiredErrorMessage"] = value; }
281 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
282 public virtual string ContinueButtonImageUrl {
283 get { return ViewState.GetString ("ContinueButtonImageUrl", String.Empty); }
284 set { ViewState ["ContinueButtonImageUrl"] = value; }
287 [DefaultValue (null)]
288 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
289 [NotifyParentProperty (true)]
290 [PersistenceMode (PersistenceMode.InnerProperty)]
291 public Style ContinueButtonStyle {
293 if (_continueButtonStyle == null) {
294 _continueButtonStyle = new Style ();
295 if (IsTrackingViewState)
296 _continueButtonStyle.TrackViewState ();
298 return _continueButtonStyle;
303 public virtual string ContinueButtonText {
304 get { return ViewState.GetString ("ContinueButtonText", "Continue"); }
305 set { ViewState ["ContinueButtonText"] = value; }
308 [DefaultValue (ButtonType.Button)]
309 public virtual ButtonType ContinueButtonType {
310 get { return ViewState ["ContinueButtonType"] == null ? ButtonType.Button : (ButtonType) ViewState ["ContinueButtonType"]; }
311 set { ViewState ["ContinueButtonType"] = value; }
317 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
318 public virtual string ContinueDestinationPageUrl {
319 get { return ViewState.GetString ("ContinueDestinationPageUrl", String.Empty); }
320 set { ViewState ["ContinueDestinationPageUrl"] = value; }
325 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
326 public virtual string CreateUserIconUrl {
327 get { return ViewState.GetString ("CreateUserIconUrl", String.Empty); }
328 set { ViewState ["CreateUserIconUrl"] = value; }
333 public virtual string CreateUserText {
334 get { return ViewState.GetString ("CreateUserText", String.Empty); }
335 set { ViewState ["CreateUserText"] = value; }
340 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
341 public virtual string CreateUserUrl {
342 get { return ViewState.GetString ("CreateUserUrl", String.Empty); }
343 set { ViewState ["CreateUserUrl"] = value; }
346 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
350 public virtual string CurrentPassword {
351 get { return _currentPassword != null ? _currentPassword : String.Empty; }
354 [DefaultValue (false)]
355 public virtual bool DisplayUserName {
356 get { return ViewState.GetBool ("DisplayUserName", false); }
357 set { ViewState ["DisplayUserName"] = value; }
362 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
363 public virtual string EditProfileIconUrl {
364 get { return ViewState.GetString ("EditProfileIconUrl", String.Empty); }
365 set { ViewState ["EditProfileIconUrl"] = value; }
370 public virtual string EditProfileText {
371 get { return ViewState.GetString ("EditProfileText", String.Empty); }
372 set { ViewState ["EditProfileText"] = value; }
377 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
378 public virtual string EditProfileUrl {
379 get { return ViewState.GetString ("EditProfileUrl", String.Empty); }
380 set { ViewState ["EditProfileUrl"] = value; }
383 [DefaultValue (null)]
384 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
385 [NotifyParentProperty (true)]
386 [PersistenceMode (PersistenceMode.InnerProperty)]
387 public TableItemStyle FailureTextStyle {
389 if (_failureTextStyle == null) {
390 _failureTextStyle = new TableItemStyle ();
391 if (IsTrackingViewState)
392 _failureTextStyle.TrackViewState ();
394 return _failureTextStyle;
400 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
401 public virtual string HelpPageIconUrl {
402 get { return ViewState.GetString ("HelpPageIconUrl", String.Empty); }
403 set { ViewState ["HelpPageIconUrl"] = value; }
408 public virtual string HelpPageText {
409 get { return ViewState.GetString ("HelpPageText", String.Empty); }
410 set { ViewState ["HelpPageText"] = value; }
415 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
416 public virtual string HelpPageUrl {
417 get { return ViewState.GetString ("HelpPageUrl", String.Empty); }
418 set { ViewState ["HelpPageUrl"] = value; }
421 [DefaultValue (null)]
422 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
423 [NotifyParentProperty (true)]
424 [PersistenceMode (PersistenceMode.InnerProperty)]
425 public TableItemStyle HyperLinkStyle {
427 if (_hyperLinkStyle == null) {
428 _hyperLinkStyle = new TableItemStyle ();
429 if (IsTrackingViewState)
430 _hyperLinkStyle.TrackViewState ();
432 return _hyperLinkStyle;
438 public virtual string InstructionText {
439 get { return ViewState.GetString ("InstructionText", String.Empty); }
440 set { ViewState ["InstructionText"] = value; }
443 [DefaultValue (null)]
444 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
445 [NotifyParentProperty (true)]
446 [PersistenceMode (PersistenceMode.InnerProperty)]
447 public TableItemStyle InstructionTextStyle {
449 if (_instructionTextStyle == null) {
450 _instructionTextStyle = new TableItemStyle ();
451 if (IsTrackingViewState)
452 _instructionTextStyle.TrackViewState ();
454 return _instructionTextStyle;
458 [DefaultValue (null)]
459 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
460 [NotifyParentProperty (true)]
461 [PersistenceMode (PersistenceMode.InnerProperty)]
462 public TableItemStyle LabelStyle {
464 if (_labelStyle == null) {
465 _labelStyle = new TableItemStyle ();
466 if (IsTrackingViewState)
467 _labelStyle.TrackViewState ();
474 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
475 [NotifyParentProperty (true)]
476 [PersistenceMode (PersistenceMode.InnerProperty)]
477 public MailDefinition MailDefinition {
479 if (_mailDefinition == null) {
480 _mailDefinition = new MailDefinition ();
481 if (IsTrackingViewState)
482 ((IStateManager) _mailDefinition).TrackViewState ();
484 return _mailDefinition;
490 public virtual string MembershipProvider {
492 object o = ViewState ["MembershipProvider"];
493 return (o == null) ? String.Empty : (string) o;
498 ViewState.Remove ("MembershipProvider");
500 ViewState ["MembershipProvider"] = value;
508 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
510 public virtual string NewPassword {
511 get { return _newPassword != null ? _newPassword : String.Empty; }
515 public virtual string NewPasswordLabelText {
516 get { return ViewState.GetString ("NewPasswordLabelText", "New Password:"); }
517 set { ViewState ["NewPasswordLabelText"] = value; }
520 public virtual string NewPasswordRegularExpression {
521 get { return ViewState.GetString ("NewPasswordRegularExpression", String.Empty); }
522 set { ViewState ["NewPasswordRegularExpression"] = value; }
525 public virtual string NewPasswordRegularExpressionErrorMessage {
526 get { return ViewState.GetString ("NewPasswordRegularExpressionErrorMessage", String.Empty); }
527 set { ViewState ["NewPasswordRegularExpressionErrorMessage"] = value; }
531 public virtual string NewPasswordRequiredErrorMessage {
532 get { return ViewState.GetString ("NewPasswordRequiredErrorMessage", "New Password is required."); }
533 set { ViewState ["NewPasswordRequiredErrorMessage"] = value; }
536 [DefaultValue (null)]
537 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
538 [NotifyParentProperty (true)]
539 [PersistenceMode (PersistenceMode.InnerProperty)]
540 public TableItemStyle PasswordHintStyle {
542 if (_passwordHintStyle == null) {
543 _passwordHintStyle = new TableItemStyle ();
544 if (IsTrackingViewState)
545 _passwordHintStyle.TrackViewState ();
547 return _passwordHintStyle;
553 public virtual string PasswordHintText {
554 get { return ViewState.GetString ("PasswordHintText", String.Empty); }
555 set { ViewState ["PasswordHintText"] = value; }
559 public virtual string PasswordLabelText {
560 get { return ViewState.GetString ("PasswordLabelText", "Password:"); }
561 set { ViewState ["PasswordLabelText"] = value; }
566 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
567 public virtual string PasswordRecoveryIconUrl {
568 get { return ViewState.GetString ("PasswordRecoveryIconUrl", String.Empty); }
569 set { ViewState ["PasswordRecoveryIconUrl"] = value; }
574 public virtual string PasswordRecoveryText {
575 get { return ViewState.GetString ("PasswordRecoveryText", String.Empty); }
576 set { ViewState ["PasswordRecoveryText"] = value; }
581 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
582 public virtual string PasswordRecoveryUrl {
583 get { return ViewState.GetString ("PasswordRecoveryUrl", String.Empty); }
584 set { ViewState ["PasswordRecoveryUrl"] = value; }
588 public virtual string PasswordRequiredErrorMessage {
589 get { return ViewState.GetString ("PasswordRequiredErrorMessage", String.Empty); }
590 set { ViewState ["PasswordRequiredErrorMessage"] = value; }
593 // LAMESPEC: MSDN claims it's present in 3.5, but it's not
594 [DefaultValue (true)]
595 public virtual bool RenderOuterTable {
596 get { return renderOuterTable; }
597 set { renderOuterTable = value; }
602 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
604 public virtual string SuccessPageUrl {
605 get { return ViewState.GetString ("SuccessPageUrl", String.Empty); }
606 set { ViewState ["SuccessPageUrl"] = value; }
609 [PersistenceMode (PersistenceMode.InnerProperty)]
610 [TemplateContainer (typeof (ChangePassword))]
612 public virtual ITemplate SuccessTemplate {
613 get { return _successTemplate; }
614 set { _successTemplate = value; }
618 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
619 public Control SuccessTemplateContainer {
621 if (_successTemplateContainer == null)
622 _successTemplateContainer = new SuccessContainer (this);
623 return _successTemplateContainer;
629 public virtual string SuccessText {
630 get { return ViewState.GetString ("SuccessText", "Your password has been changed!"); }
631 set { ViewState ["SuccessText"] = value; }
634 [DefaultValue (null)]
635 [NotifyParentProperty (true)]
636 [PersistenceMode (PersistenceMode.InnerProperty)]
637 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
638 public TableItemStyle SuccessTextStyle {
640 if (_successTextStyle == null) {
641 _successTextStyle = new TableItemStyle ();
642 if (IsTrackingViewState)
643 _successTextStyle.TrackViewState ();
645 return _successTextStyle;
650 public virtual string SuccessTitleText {
651 get { return ViewState.GetString ("SuccessTitleText", "Change Password Complete"); }
652 set { ViewState ["SuccessTitleText"] = value; }
655 [DefaultValue (null)]
656 [NotifyParentProperty (true)]
657 [PersistenceMode (PersistenceMode.InnerProperty)]
658 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
659 public Style TextBoxStyle {
661 if (_textBoxStyle == null) {
662 _textBoxStyle = new Style ();
663 if (IsTrackingViewState)
664 _textBoxStyle.TrackViewState ();
666 return _textBoxStyle;
670 [DefaultValue (null)]
671 [NotifyParentProperty (true)]
672 [PersistenceMode (PersistenceMode.InnerProperty)]
673 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
674 public TableItemStyle TitleTextStyle {
676 if (_titleTextStyle == null) {
677 _titleTextStyle = new TableItemStyle ();
678 if (IsTrackingViewState)
679 _titleTextStyle.TrackViewState ();
681 return _titleTextStyle;
686 public virtual string UserName {
688 if (_username == null && HttpContext.Current.Request.IsAuthenticated)
689 _username = HttpContext.Current.User.Identity.Name;
691 return _username != null ? _username : String.Empty;
693 set { _username = value; }
697 public virtual string UserNameLabelText {
698 get { return ViewState.GetString ("UserNameLabelText", "User Name:"); }
699 set { ViewState ["UserNameLabelText"] = value; }
703 public virtual string UserNameRequiredErrorMessage {
704 get { return ViewState.GetString ("UserNameRequiredErrorMessage", "User Name is required."); }
705 set { ViewState ["UserNameRequiredErrorMessage"] = value; }
708 [DefaultValue (null)]
709 [NotifyParentProperty (true)]
710 [PersistenceMode (PersistenceMode.InnerProperty)]
711 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
712 public Style ValidatorTextStyle {
714 if (_validatorTextStyle == null) {
715 _validatorTextStyle = new Style ();
716 if (IsTrackingViewState)
717 _validatorTextStyle.TrackViewState ();
719 return _validatorTextStyle;
725 #region Protected Methods
727 protected internal override void CreateChildControls ()
731 ITemplate cpTemplate = ChangePasswordTemplate;
732 if (cpTemplate == null)
733 cpTemplate = new ChangePasswordDeafultTemplate (this);
734 ((ChangePasswordContainer) ChangePasswordTemplateContainer).InstantiateTemplate (cpTemplate);
736 ITemplate sTemplate = SuccessTemplate;
737 if (sTemplate == null)
738 sTemplate = new SuccessDefaultTemplate (this);
739 ((SuccessContainer) SuccessTemplateContainer).InstantiateTemplate (sTemplate);
741 Controls.AddAt (0, ChangePasswordTemplateContainer);
742 Controls.AddAt (1, SuccessTemplateContainer);
744 IEditableTextControl editable;
746 ChangePasswordContainer container = (ChangePasswordContainer) ChangePasswordTemplateContainer;
747 if (DisplayUserName) {
748 editable = container.UserNameTextBox;
749 if (editable != null)
750 editable.TextChanged += new EventHandler (UserName_TextChanged);
753 editable = container.CurrentPasswordTextBox;
754 if (editable != null)
755 editable.TextChanged += new EventHandler (CurrentPassword_TextChanged);
757 editable = container.NewPasswordTextBox;
758 if (editable != null)
759 editable.TextChanged += new EventHandler (NewPassword_TextChanged);
761 editable = container.ConfirmNewPasswordTextBox;
762 if (editable != null)
763 editable.TextChanged += new EventHandler (NewPasswordConfirm_TextChanged);
766 protected internal override void Render (HtmlTextWriter writer)
769 VerifyInlinePropertiesNotSet ();
771 for (int i = 0; i < Controls.Count; i++)
772 if (Controls [i].Visible)
773 Controls [i].Render (writer);
778 #region Private Methods
780 [MonoTODO ("Not implemented")]
781 protected override void SetDesignModeState (IDictionary data)
783 throw new NotImplementedException ();
786 void InitMemberShipProvider ()
788 string mp = MembershipProvider;
789 _provider = (mp.Length == 0) ? Membership.Provider : Membership.Providers [mp];
790 if (_provider == null)
791 throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
794 void ProcessChangePasswordEvent (CommandEventArgs args)
799 LoginCancelEventArgs loginCancelEventArgs = new LoginCancelEventArgs ();
800 OnChangingPassword (loginCancelEventArgs);
801 if (loginCancelEventArgs.Cancel)
806 res = MembershipProviderInternal.ChangePassword (UserName, CurrentPassword, NewPassword);
811 OnChangedPassword (args);
812 _showContinue = true;
814 if (_mailDefinition != null)
815 SendMail (UserName, NewPassword);
817 OnChangePasswordError (EventArgs.Empty);
818 string lastError = string.Format (
819 "Password incorrect or New Password invalid. New Password length minimum: {0}. Non-alphanumeric characters required: {1}.",
820 MembershipProviderInternal.MinRequiredPasswordLength,
821 MembershipProviderInternal.MinRequiredNonAlphanumericCharacters);
823 ChangePasswordContainer container = (ChangePasswordContainer) ChangePasswordTemplateContainer;
824 container.FailureTextLiteral.Text = lastError;
825 _showContinue = false;
831 void ProcessCancelEvent (CommandEventArgs args)
833 OnCancelButtonClick (args);
835 if (ContinueDestinationPageUrl.Length > 0)
836 Context.Response.Redirect (ContinueDestinationPageUrl);
841 void ProcessContinueEvent (CommandEventArgs args)
843 OnContinueButtonClick (args);
845 if (ContinueDestinationPageUrl.Length > 0)
846 Context.Response.Redirect (ContinueDestinationPageUrl);
851 void SendMail (string username, string password)
853 MembershipUser user = MembershipProviderInternal.GetUser (UserName, false);
857 ListDictionary dictionary = new ListDictionary ();
858 dictionary.Add ("<%USERNAME%>", username);
859 dictionary.Add ("<%PASSWORD%>", password);
861 MailMessage message = MailDefinition.CreateMailMessage (user.Email, dictionary, this);
863 MailMessageEventArgs args = new MailMessageEventArgs (message);
864 OnSendingMail (args);
866 SmtpClient smtpClient = new SmtpClient ();
868 smtpClient.Send (message);
869 } catch (Exception e) {
870 SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e);
871 OnSendMailError (mailArgs);
872 if (!mailArgs.Handled)
881 protected override HtmlTextWriterTag TagKey {
882 get { return HtmlTextWriterTag.Table; }
885 internal virtual MembershipProvider MembershipProviderInternal {
887 if (_provider == null)
888 InitMemberShipProvider ();
896 #region View and Control State
898 protected internal override void LoadControlState (object savedState)
900 if (savedState == null)
902 object [] state = (object []) savedState;
903 base.LoadControlState (state [0]);
905 _showContinue = (bool) state [1];
906 _username = (string) state [2];
909 protected internal override object SaveControlState ()
911 object state = base.SaveControlState ();
912 return new object [] { state, _showContinue, _username };
915 protected override void LoadViewState (object savedState)
917 if (savedState == null)
920 object [] states = (object []) savedState;
921 base.LoadViewState (states [0]);
923 if (states [1] != null)
924 CancelButtonStyle.LoadViewState (states [1]);
925 if (states [2] != null)
926 ChangePasswordButtonStyle.LoadViewState (states [2]);
927 if (states [3] != null)
928 ContinueButtonStyle.LoadViewState (states [3]);
930 if (states [4] != null)
931 FailureTextStyle.LoadViewState (states [4]);
932 if (states [5] != null)
933 HyperLinkStyle.LoadViewState (states [5]);
934 if (states [6] != null)
935 InstructionTextStyle.LoadViewState (states [6]);
937 if (states [7] != null)
938 LabelStyle.LoadViewState (states [7]);
939 if (states [8] != null)
940 PasswordHintStyle.LoadViewState (states [8]);
941 if (states [9] != null)
942 SuccessTextStyle.LoadViewState (states [9]);
944 if (states [10] != null)
945 TextBoxStyle.LoadViewState (states [10]);
946 if (states [11] != null)
947 TitleTextStyle.LoadViewState (states [11]);
948 if (states [12] != null)
949 ValidatorTextStyle.LoadViewState (states [12]);
951 if (states [13] != null)
952 ((IStateManager) MailDefinition).LoadViewState (states [13]);
955 protected override object SaveViewState ()
957 object [] states = new object [14];
958 states [0] = base.SaveViewState ();
960 if (_cancelButtonStyle != null)
961 states [1] = _cancelButtonStyle.SaveViewState ();
962 if (_changePasswordButtonStyle != null)
963 states [2] = _changePasswordButtonStyle.SaveViewState ();
964 if (_continueButtonStyle != null)
965 states [3] = _continueButtonStyle.SaveViewState ();
967 if (_failureTextStyle != null)
968 states [4] = _failureTextStyle.SaveViewState ();
969 if (_hyperLinkStyle != null)
970 states [5] = _hyperLinkStyle.SaveViewState ();
971 if (_instructionTextStyle != null)
972 states [6] = _instructionTextStyle.SaveViewState ();
974 if (_labelStyle != null)
975 states [7] = _labelStyle.SaveViewState ();
976 if (_passwordHintStyle != null)
977 states [8] = _passwordHintStyle.SaveViewState ();
978 if (_successTextStyle != null)
979 states [9] = _successTextStyle.SaveViewState ();
981 if (_textBoxStyle != null)
982 states [10] = _textBoxStyle.SaveViewState ();
983 if (_titleTextStyle != null)
984 states [11] = _titleTextStyle.SaveViewState ();
985 if (_validatorTextStyle != null)
986 states [12] = _validatorTextStyle.SaveViewState ();
988 if (_mailDefinition != null)
989 states [13] = ((IStateManager) _mailDefinition).SaveViewState ();
991 for (int i = 0; i < states.Length; i++) {
992 if (states [i] != null)
998 protected override void TrackViewState ()
1000 base.TrackViewState ();
1002 if (_cancelButtonStyle != null)
1003 _cancelButtonStyle.TrackViewState ();
1004 if (_changePasswordButtonStyle != null)
1005 _changePasswordButtonStyle.TrackViewState ();
1006 if (_continueButtonStyle != null)
1007 _continueButtonStyle.TrackViewState ();
1009 if (_failureTextStyle != null)
1010 _failureTextStyle.TrackViewState ();
1011 if (_hyperLinkStyle != null)
1012 _hyperLinkStyle.TrackViewState ();
1013 if (_instructionTextStyle != null)
1014 _instructionTextStyle.TrackViewState ();
1016 if (_labelStyle != null)
1017 _labelStyle.TrackViewState ();
1018 if (_passwordHintStyle != null)
1019 _passwordHintStyle.TrackViewState ();
1020 if (_successTextStyle != null)
1021 _successTextStyle.TrackViewState ();
1023 if (_textBoxStyle != null)
1024 _textBoxStyle.TrackViewState ();
1025 if (_titleTextStyle != null)
1026 _titleTextStyle.TrackViewState ();
1027 if (_validatorTextStyle != null)
1028 _validatorTextStyle.TrackViewState ();
1030 if (_mailDefinition != null)
1031 ((IStateManager) _mailDefinition).TrackViewState ();
1036 #region Event Handlers
1038 protected override bool OnBubbleEvent (object source, EventArgs e)
1040 CommandEventArgs args = e as CommandEventArgs;
1042 if (args.CommandName == ChangePasswordButtonCommandName) {
1043 ProcessChangePasswordEvent (args);
1047 if (args.CommandName == CancelButtonCommandName) {
1048 ProcessCancelEvent (args);
1052 if (args.CommandName == ContinueButtonCommandName) {
1053 ProcessContinueEvent (args);
1057 return base.OnBubbleEvent (source, e);
1060 protected virtual void OnCancelButtonClick (EventArgs e)
1062 EventHandler eh = events [cancelButtonClickEvent] as EventHandler;
1067 protected virtual void OnChangedPassword (EventArgs e)
1069 EventHandler eh = events [changedPasswordEvent] as EventHandler;
1074 protected virtual void OnChangePasswordError (EventArgs e)
1076 EventHandler eh = events [changePasswordErrorEvent] as EventHandler;
1081 protected virtual void OnChangingPassword (LoginCancelEventArgs e)
1083 LoginCancelEventHandler eh = events [changingPasswordEvent] as LoginCancelEventHandler;
1088 protected virtual void OnContinueButtonClick (EventArgs e)
1090 EventHandler eh = events [continueButtonClickEvent] as EventHandler;
1095 protected internal override void OnInit (EventArgs e)
1097 Page.RegisterRequiresControlState (this);
1101 protected internal override void OnPreRender (EventArgs e)
1103 ChangePasswordTemplateContainer.Visible = !_showContinue;
1104 SuccessTemplateContainer.Visible = _showContinue;
1105 base.OnPreRender (e);
1108 protected virtual void OnSendingMail (MailMessageEventArgs e)
1110 MailMessageEventHandler eh = events [sendingMailEvent] as MailMessageEventHandler;
1115 protected virtual void OnSendMailError (SendMailErrorEventArgs e)
1117 SendMailErrorEventHandler eh = events [sendMailErrorEvent] as SendMailErrorEventHandler;
1122 void UserName_TextChanged (object sender, EventArgs e)
1124 UserName = ((ITextControl) sender).Text;
1127 void CurrentPassword_TextChanged (object sender, EventArgs e)
1129 _currentPassword = ((ITextControl) sender).Text;
1132 void NewPassword_TextChanged (object sender, EventArgs e)
1134 _newPassword = ((ITextControl) sender).Text;
1137 void NewPasswordConfirm_TextChanged (object sender, EventArgs e)
1139 _newPasswordConfirm = ((ITextControl) sender).Text;
1144 class BaseChangePasswordContainer : Control, INamingContainer, INonBindingContainer
1146 protected readonly ChangePassword _owner = null;
1148 bool renderOuterTable;
1150 Table _table = null;
1151 TableCell _containerCell = null;
1153 public BaseChangePasswordContainer (ChangePassword owner)
1156 throw new ArgumentNullException ("owner");
1160 renderOuterTable = _owner.RenderOuterTable;
1162 if (renderOuterTable)
1167 public void InstantiateTemplate (ITemplate template)
1170 if (!_owner.RenderOuterTable)
1171 template.InstantiateIn (this);
1174 template.InstantiateIn (_containerCell);
1179 _table = new Table ();
1181 string id = _owner.ID;
1182 if (!String.IsNullOrEmpty (id))
1184 _table.Attributes.Add ("id", _owner.ID);
1186 _table.CellSpacing = 0;
1187 _table.CellPadding = _owner.BorderPadding;
1189 _containerCell = new TableCell ();
1191 TableRow row = new TableRow ();
1192 row.Cells.Add (_containerCell);
1193 _table.Rows.Add (row);
1195 Controls.AddAt (0, _table);
1198 protected internal override void OnPreRender (EventArgs e)
1201 _table.ApplyStyle (_owner.ControlStyle);
1202 base.OnPreRender (e);
1205 protected override void EnsureChildControls ()
1207 base.EnsureChildControls ();
1209 // it's the owner who adds controls, not us
1211 _owner.EnsureChildControls ();
1215 sealed class ChangePasswordContainer : BaseChangePasswordContainer
1217 public ChangePasswordContainer (ChangePassword owner) : base (owner)
1219 ID = "ChangePasswordContainerID";
1222 // Requried controls
1223 public IEditableTextControl UserNameTextBox {
1225 Control c = FindControl ("UserName");
1227 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID UserName for the username, this is required if DisplayUserName=true.");
1228 return c as IEditableTextControl;
1232 public IEditableTextControl CurrentPasswordTextBox {
1234 Control c = FindControl ("CurrentPassword");
1236 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID CurrentPassword for the current password.");
1237 return c as IEditableTextControl;
1241 public IEditableTextControl NewPasswordTextBox {
1243 Control c = FindControl ("NewPassword");
1245 throw new HttpException ("ChangePasswordTemplate does not contain an IEditableTextControl with ID NewPassword for the new password.");
1246 return c as IEditableTextControl;
1250 // Optional controls
1251 public IEditableTextControl ConfirmNewPasswordTextBox {
1252 get { return FindControl ("ConfirmNewPassword") as IEditableTextControl; }
1255 public Control CancelButton {
1256 get { return FindControl ("Cancel"); }
1259 public Control ChangePasswordButton {
1260 get { return FindControl ("ChangePassword"); }
1263 public ITextControl FailureTextLiteral {
1264 get { return FindControl ("FailureText") as ITextControl; }
1268 sealed class ChangePasswordDeafultTemplate : ITemplate
1270 readonly ChangePassword _owner = null;
1272 internal ChangePasswordDeafultTemplate (ChangePassword cPassword)
1277 TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1)
1279 TableRow row = new TableRow ();
1280 TableCell cell0 = new TableCell ();
1281 TableCell cell1 = new TableCell ();
1283 cell0.Controls.Add (c0);
1284 row.Controls.Add (cell0);
1286 if ((c1 != null) && (c2 != null)) {
1287 cell1.Controls.Add (c1);
1288 cell1.Controls.Add (c2);
1289 cell0.HorizontalAlign = HorizontalAlign.Right;
1292 cell0.ApplyStyle (s0);
1294 cell1.ApplyStyle (s1);
1296 row.Controls.Add (cell1);
1298 cell0.ColumnSpan = 2;
1299 cell0.HorizontalAlign = HorizontalAlign.Center;
1301 cell0.ApplyStyle (s0);
1306 bool AddLink (string pageUrl, string linkText, string linkIcon, WebControl container)
1309 if (linkIcon.Length > 0) {
1310 Image img = new Image ();
1311 img.ImageUrl = linkIcon;
1312 container.Controls.Add (img);
1315 if (linkText.Length > 0) {
1316 HyperLink link = new HyperLink ();
1317 link.NavigateUrl = pageUrl;
1318 link.Text = linkText;
1319 link.ControlStyle.CopyTextStylesFrom (container.ControlStyle);
1320 container.Controls.Add (link);
1326 public void InstantiateIn (Control container)
1328 Table table = new Table ();
1329 table.CellPadding = 0;
1331 Style ownerStyle = _owner.ControlStyle;
1332 Style tableStyle = table.ControlStyle;
1333 FontInfo ownerFont = ownerStyle.Font;
1335 tableStyle.Font.CopyFrom (ownerFont);
1336 ownerFont.ClearDefaults ();
1338 Color ownerForeColor = ownerStyle.ForeColor;
1339 if (ownerForeColor != Color.Empty) {
1340 tableStyle.ForeColor = ownerForeColor;
1341 ownerStyle.RemoveBit ((int)global::System.Web.UI.WebControls.Style.Styles.ForeColor);
1345 table.Controls.Add (
1346 CreateRow (new LiteralControl (_owner.ChangePasswordTitleText),
1347 null, null, _owner.TitleTextStyle, null));
1350 if (_owner.InstructionText.Length > 0) {
1351 table.Controls.Add (
1352 CreateRow (new LiteralControl (_owner.InstructionText),
1353 null, null, _owner.InstructionTextStyle, null));
1357 if (_owner.DisplayUserName) {
1358 TextBox UserName = new TextBox ();
1359 UserName.ID = "UserName";
1360 UserName.Text = _owner.UserName;
1361 UserName.ApplyStyle (_owner.TextBoxStyle);
1363 Label UserNameLabel = new Label ();
1364 UserNameLabel.ID = "UserNameLabel";
1365 UserNameLabel.AssociatedControlID = "UserName";
1366 UserNameLabel.Text = _owner.UserNameLabelText;
1368 RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
1369 UserNameRequired.ID = "UserNameRequired";
1370 UserNameRequired.ControlToValidate = "UserName";
1371 UserNameRequired.ErrorMessage = _owner.UserNameRequiredErrorMessage;
1372 UserNameRequired.ToolTip = _owner.UserNameRequiredErrorMessage;
1373 UserNameRequired.Text = "*";
1374 UserNameRequired.ValidationGroup = _owner.ID;
1375 UserNameRequired.ApplyStyle (_owner.ValidatorTextStyle);
1377 table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _owner.LabelStyle, null));
1381 TextBox CurrentPassword = new TextBox ();
1382 CurrentPassword.ID = "CurrentPassword";
1383 CurrentPassword.TextMode = TextBoxMode.Password;
1384 CurrentPassword.ApplyStyle (_owner.TextBoxStyle);
1386 Label CurrentPasswordLabel = new Label ();
1387 CurrentPasswordLabel.ID = "CurrentPasswordLabel";
1388 CurrentPasswordLabel.AssociatedControlID = "CurrentPasswordLabel";
1389 CurrentPasswordLabel.Text = _owner.PasswordLabelText;
1391 RequiredFieldValidator CurrentPasswordRequired = new RequiredFieldValidator ();
1392 CurrentPasswordRequired.ID = "CurrentPasswordRequired";
1393 CurrentPasswordRequired.ControlToValidate = "CurrentPassword";
1394 CurrentPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1395 CurrentPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1396 CurrentPasswordRequired.Text = "*";
1397 CurrentPasswordRequired.ValidationGroup = _owner.ID;
1398 CurrentPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1400 table.Controls.Add (CreateRow (CurrentPasswordLabel, CurrentPassword, CurrentPasswordRequired, _owner.LabelStyle, null));
1403 TextBox NewPassword = new TextBox ();
1404 NewPassword.ID = "NewPassword";
1405 NewPassword.TextMode = TextBoxMode.Password;
1406 NewPassword.ApplyStyle (_owner.TextBoxStyle);
1408 Label NewPasswordLabel = new Label ();
1409 NewPasswordLabel.ID = "NewPasswordLabel";
1410 NewPasswordLabel.AssociatedControlID = "NewPassword";
1411 NewPasswordLabel.Text = _owner.NewPasswordLabelText;
1413 RequiredFieldValidator NewPasswordRequired = new RequiredFieldValidator ();
1414 NewPasswordRequired.ID = "NewPasswordRequired";
1415 NewPasswordRequired.ControlToValidate = "NewPassword";
1416 NewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1417 NewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1418 NewPasswordRequired.Text = "*";
1419 NewPasswordRequired.ValidationGroup = _owner.ID;
1420 NewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1422 table.Controls.Add (CreateRow (NewPasswordLabel, NewPassword, NewPasswordRequired, _owner.LabelStyle, null));
1425 if (_owner.PasswordHintText.Length > 0) {
1426 table.Controls.Add (
1427 CreateRow (new LiteralControl (String.Empty),
1428 new LiteralControl (_owner.PasswordHintText),
1429 new LiteralControl (String.Empty),
1430 null, _owner.PasswordHintStyle));
1434 TextBox ConfirmNewPassword = new TextBox ();
1435 ConfirmNewPassword.ID = "ConfirmNewPassword";
1436 ConfirmNewPassword.TextMode = TextBoxMode.Password;
1437 ConfirmNewPassword.ApplyStyle (_owner.TextBoxStyle);
1439 Label ConfirmNewPasswordLabel = new Label ();
1440 ConfirmNewPasswordLabel.ID = "ConfirmNewPasswordLabel";
1441 ConfirmNewPasswordLabel.AssociatedControlID = "ConfirmNewPasswordLabel";
1442 ConfirmNewPasswordLabel.Text = _owner.ConfirmNewPasswordLabelText;
1444 RequiredFieldValidator ConfirmNewPasswordRequired = new RequiredFieldValidator ();
1445 ConfirmNewPasswordRequired.ID = "ConfirmNewPasswordRequired";
1446 ConfirmNewPasswordRequired.ControlToValidate = "ConfirmNewPassword";
1447 ConfirmNewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
1448 ConfirmNewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
1449 ConfirmNewPasswordRequired.Text = "*";
1450 ConfirmNewPasswordRequired.ValidationGroup = _owner.ID;
1451 ConfirmNewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);
1453 table.Controls.Add (CreateRow (ConfirmNewPasswordLabel, ConfirmNewPassword, ConfirmNewPasswordRequired, _owner.LabelStyle, null));
1456 CompareValidator NewPasswordCompare = new CompareValidator ();
1457 NewPasswordCompare.ID = "NewPasswordCompare";
1458 NewPasswordCompare.ControlToCompare = "NewPassword";
1459 NewPasswordCompare.ControlToValidate = "ConfirmNewPassword";
1460 NewPasswordCompare.Display = ValidatorDisplay.Dynamic;
1461 NewPasswordCompare.ErrorMessage = _owner.ConfirmPasswordCompareErrorMessage;
1462 NewPasswordCompare.ValidationGroup = _owner.ID;
1464 table.Controls.Add (CreateRow (NewPasswordCompare, null, null, null, null));
1467 Literal FailureTextLiteral = new Literal ();
1468 FailureTextLiteral.ID = "FailureText";
1469 FailureTextLiteral.EnableViewState = false;
1471 if (_owner.FailureTextStyle.ForeColor.IsEmpty)
1472 _owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
1474 table.Controls.Add (CreateRow (FailureTextLiteral, null, null, _owner.FailureTextStyle, null));
1477 WebControl ChangePasswordButton = null;
1478 switch (_owner.ChangePasswordButtonType) {
1479 case ButtonType.Button:
1480 ChangePasswordButton = new Button ();
1482 case ButtonType.Image:
1483 ChangePasswordButton = new ImageButton ();
1485 case ButtonType.Link:
1486 ChangePasswordButton = new LinkButton ();
1490 ChangePasswordButton.ID = "ChangePasswordPushButton";
1491 ChangePasswordButton.ApplyStyle (_owner.ChangePasswordButtonStyle);
1492 ((IButtonControl) ChangePasswordButton).CommandName = ChangePassword.ChangePasswordButtonCommandName;
1493 ((IButtonControl) ChangePasswordButton).Text = _owner.ChangePasswordButtonText;
1494 ((IButtonControl) ChangePasswordButton).ValidationGroup = _owner.ID;
1496 WebControl CancelButton = null;
1497 switch (_owner.CancelButtonType) {
1498 case ButtonType.Button:
1499 CancelButton = new Button ();
1501 case ButtonType.Image:
1502 CancelButton = new ImageButton ();
1504 case ButtonType.Link:
1505 CancelButton = new LinkButton ();
1509 CancelButton.ID = "CancelPushButton";
1510 CancelButton.ApplyStyle (_owner.CancelButtonStyle);
1511 ((IButtonControl) CancelButton).CommandName = ChangePassword.CancelButtonCommandName;
1512 ((IButtonControl) CancelButton).Text = _owner.CancelButtonText;
1513 ((IButtonControl) CancelButton).CausesValidation = false;
1515 table.Controls.Add (CreateRow (ChangePasswordButton, CancelButton, new LiteralControl (String.Empty), null, null));
1518 TableRow linksRow = new TableRow ();
1519 TableCell linksCell = new TableCell ();
1520 linksCell.ColumnSpan = 2;
1521 linksCell.ControlStyle.CopyFrom (_owner.HyperLinkStyle);
1523 linksRow.Cells.Add (linksCell);
1525 if (AddLink (_owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, linksCell))
1526 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1528 if (AddLink (_owner.CreateUserUrl, _owner.CreateUserText, _owner.CreateUserIconUrl, linksCell))
1529 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1531 if (AddLink (_owner.PasswordRecoveryUrl, _owner.PasswordRecoveryText, _owner.PasswordRecoveryIconUrl, linksCell))
1532 linksCell.Controls.Add (new LiteralControl ("<br/>"));
1534 AddLink (_owner.EditProfileUrl, _owner.EditProfileText, _owner.EditProfileIconUrl, linksCell);
1536 table.Controls.Add (linksRow);
1538 container.Controls.Add (table);
1542 sealed class SuccessDefaultTemplate : ITemplate
1544 readonly ChangePassword _cPassword = null;
1546 internal SuccessDefaultTemplate (ChangePassword cPassword)
1548 _cPassword = cPassword;
1551 TableRow CreateRow (Control c0, Style s0, HorizontalAlign align)
1553 TableRow row = new TableRow ();
1554 TableCell cell0 = new TableCell ();
1556 cell0.Controls.Add (c0);
1557 cell0.HorizontalAlign = align;
1559 cell0.ApplyStyle (s0);
1561 row.Controls.Add (cell0);
1565 public void InstantiateIn (Control container)
1567 Table table = new Table ();
1568 table.ControlStyle.Width = Unit.Percentage (100);
1569 table.ControlStyle.Height = Unit.Percentage (100);
1572 table.Controls.Add (
1573 CreateRow (new LiteralControl (_cPassword.SuccessTitleText), _cPassword.TitleTextStyle, HorizontalAlign.Center));
1576 table.Controls.Add (
1577 CreateRow (new LiteralControl (_cPassword.SuccessText), _cPassword.SuccessTextStyle, HorizontalAlign.Center));
1580 WebControl ContinueButton = null;
1581 switch (_cPassword.ChangePasswordButtonType) {
1582 case ButtonType.Button:
1583 ContinueButton = new Button ();
1585 case ButtonType.Image:
1586 ContinueButton = new ImageButton ();
1588 case ButtonType.Link:
1589 ContinueButton = new LinkButton ();
1593 ContinueButton.ID = "ContinuePushButton";
1594 ContinueButton.ApplyStyle (_cPassword.ContinueButtonStyle);
1595 ((IButtonControl) ContinueButton).CommandName = ChangePassword.ContinueButtonCommandName;
1596 ((IButtonControl) ContinueButton).Text = _cPassword.ContinueButtonText;
1597 ((IButtonControl) ContinueButton).CausesValidation = false;
1599 table.Controls.Add (
1600 CreateRow (ContinueButton, null, HorizontalAlign.Right));
1602 container.Controls.Add (table);
1606 sealed class SuccessContainer : BaseChangePasswordContainer
1608 public SuccessContainer (ChangePassword owner) : base (owner)
1610 ID = "SuccessContainerID";
1613 public Control ChangePasswordButton
1615 get { return FindControl ("Continue"); }