1 //------------------------------------------------------------------------------
2 // <copyright file="ChangePassword.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
7 namespace System.Web.UI.WebControls {
9 using System.Collections;
10 using System.Collections.Specialized;
11 using System.ComponentModel;
12 using System.Diagnostics.CodeAnalysis;
14 using System.Drawing.Design;
15 using System.Globalization;
16 using System.Net.Mail;
17 using System.Security.Permissions;
18 using System.Web.Configuration;
19 using System.Web.Management;
20 using System.Web.Security;
24 /// Displays UI that allows a user to change his password. Uses a Membership provider
25 /// or custom authentication logic in the OnAuthenticate event. UI can be customized
26 /// using control properties or a template.
30 DefaultEvent("ChangedPassword"),
31 Designer("System.Web.UI.Design.WebControls.ChangePasswordDesigner, " + AssemblyRef.SystemDesign)
33 public class ChangePassword : CompositeControl, IBorderPaddingControl, INamingContainer, IRenderOuterTableControl {
34 public static readonly string ChangePasswordButtonCommandName = "ChangePassword";
35 public static readonly string CancelButtonCommandName = "Cancel";
36 public static readonly string ContinueButtonCommandName = "Continue";
38 private ITemplate _changePasswordTemplate;
39 private ChangePasswordContainer _changePasswordContainer;
40 private ITemplate _successTemplate;
41 private SuccessContainer _successContainer;
43 private string _userName;
44 private string _password;
45 private string _newPassword;
46 private string _confirmNewPassword;
48 private bool _convertingToTemplate = false;
49 private bool _renderDesignerRegion = false;
50 private View _currentView = View.ChangePassword;
52 // Needed for user template feature
53 private const string _userNameID = "UserName";
54 private const string _currentPasswordID = "CurrentPassword";
55 private const string _newPasswordID = "NewPassword";
56 private const string _confirmNewPasswordID = "ConfirmNewPassword";
57 private const string _failureTextID = "FailureText";
59 // Needed only for "convert to template" feature, otherwise unnecessary
60 private const string _userNameRequiredID = "UserNameRequired";
61 private const string _currentPasswordRequiredID = "CurrentPasswordRequired";
62 private const string _newPasswordRequiredID = "NewPasswordRequired";
63 private const string _confirmNewPasswordRequiredID = "ConfirmNewPasswordRequired";
64 private const string _newPasswordCompareID = "NewPasswordCompare";
65 private const string _newPasswordRegExpID = "NewPasswordRegExp";
66 private const string _changePasswordPushButtonID = "ChangePasswordPushButton";
67 private const string _changePasswordImageButtonID = "ChangePasswordImageButton";
68 private const string _changePasswordLinkButtonID = "ChangePasswordLinkButton";
69 private const string _cancelPushButtonID = "CancelPushButton";
70 private const string _cancelImageButtonID = "CancelImageButton";
71 private const string _cancelLinkButtonID = "CancelLinkButton";
72 private const string _continuePushButtonID = "ContinuePushButton";
73 private const string _continueImageButtonID = "ContinueImageButton";
74 private const string _continueLinkButtonID = "ContinueLinkButton";
75 private const string _passwordRecoveryLinkID = "PasswordRecoveryLink";
76 private const string _helpLinkID = "HelpLink";
77 private const string _createUserLinkID = "CreateUserLink";
78 private const string _editProfileLinkID = "EditProfileLink";
79 private const string _editProfileSuccessLinkID = "EditProfileLinkSuccess";
81 private const string _changePasswordViewContainerID = "ChangePasswordContainerID";
82 private const string _successViewContainerID = "SuccessContainerID";
84 private const ValidatorDisplay _requiredFieldValidatorDisplay = ValidatorDisplay.Static;
85 private const ValidatorDisplay _compareFieldValidatorDisplay = ValidatorDisplay.Dynamic;
86 private const ValidatorDisplay _regexpFieldValidatorDisplay = ValidatorDisplay.Dynamic;
88 private const string _userNameReplacementKey = "<%\\s*UserName\\s*%>";
89 private const string _passwordReplacementKey = "<%\\s*Password\\s*%>";
91 private const int _viewStateArrayLength = 14;
92 private Style _changePasswordButtonStyle;
93 private TableItemStyle _labelStyle;
94 private Style _textBoxStyle;
95 private TableItemStyle _hyperLinkStyle;
96 private TableItemStyle _instructionTextStyle;
97 private TableItemStyle _titleTextStyle;
98 private TableItemStyle _failureTextStyle;
99 private TableItemStyle _successTextStyle;
100 private TableItemStyle _passwordHintStyle;
101 private Style _cancelButtonStyle;
102 private Style _continueButtonStyle;
103 private Style _validatorTextStyle;
105 private MailDefinition _mailDefinition;
107 private Control _validatorRow;
108 private Control _passwordHintTableRow;
109 private Control _userNameTableRow;
111 private static readonly object EventChangePasswordError = new object();
112 private static readonly object EventCancelButtonClick = new object();
113 private static readonly object EventContinueButtonClick = new object();
114 private static readonly object EventChangingPassword = new object();
115 private static readonly object EventChangedPassword = new object();
116 private static readonly object EventSendingMail = new object();
117 private static readonly object EventSendMailError = new object();
121 WebCategory("Appearance"),
123 WebSysDescription(SR.Login_BorderPadding),
124 SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces",
125 Justification = "Interface denotes existence of property, not used for security.")
127 public virtual int BorderPadding {
129 object obj = ViewState["BorderPadding"];
130 return (obj == null) ? 1 : (int)obj;
134 throw new ArgumentOutOfRangeException("value", SR.GetString(SR.ChangePassword_InvalidBorderPadding));
136 ViewState["BorderPadding"] = value;
142 /// Gets or sets the URL of an image to be displayed for the cancel button.
145 WebCategory("Appearance"),
147 WebSysDescription(SR.ChangePassword_CancelButtonImageUrl),
148 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
151 public virtual string CancelButtonImageUrl {
153 object obj = ViewState["CancelButtonImageUrl"];
154 return (obj == null) ? String.Empty : (string) obj;
157 ViewState["CancelButtonImageUrl"] = value;
163 /// Gets the style of cancel button.
166 WebCategory("Styles"),
168 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
169 NotifyParentProperty(true),
170 PersistenceMode(PersistenceMode.InnerProperty),
171 WebSysDescription(SR.ChangePassword_CancelButtonStyle)
173 public Style CancelButtonStyle {
175 if (_cancelButtonStyle == null) {
176 _cancelButtonStyle = new Style();
177 if (IsTrackingViewState) {
178 ((IStateManager) _cancelButtonStyle).TrackViewState();
181 return _cancelButtonStyle;
187 /// Gets or sets the text to be shown for the cancel button.
191 WebCategory("Appearance"),
192 WebSysDefaultValue(SR.ChangePassword_DefaultCancelButtonText),
193 WebSysDescription(SR.ChangePassword_CancelButtonText)
195 public virtual string CancelButtonText {
197 object obj = ViewState["CancelButtonText"];
198 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultCancelButtonText) : (string) obj;
201 ViewState["CancelButtonText"] = value;
207 /// Gets or sets the type of the cancel button.
210 WebCategory("Appearance"),
211 DefaultValue(ButtonType.Button),
212 WebSysDescription(SR.ChangePassword_CancelButtonType)
214 public virtual ButtonType CancelButtonType {
216 object obj = ViewState["CancelButtonType"];
217 return (obj == null) ? ButtonType.Button : (ButtonType) obj;
220 if (value < ButtonType.Button || value > ButtonType.Link) {
221 throw new ArgumentOutOfRangeException("value");
223 ViewState["CancelButtonType"] = value;
229 /// Gets or sets the URL of an image to be displayed for the continue button.
232 WebCategory("Behavior"),
234 WebSysDescription(SR.ChangePassword_CancelDestinationPageUrl),
235 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
239 public virtual string CancelDestinationPageUrl {
241 object obj = ViewState["CancelDestinationPageUrl"];
242 return (obj == null) ? String.Empty : (string) obj;
245 ViewState["CancelDestinationPageUrl"] = value;
251 /// Gets or sets the URL of an image to be displayed for the change password button.
254 WebCategory("Appearance"),
256 WebSysDescription(SR.ChangePassword_ChangePasswordButtonImageUrl),
257 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
260 public virtual string ChangePasswordButtonImageUrl {
262 object obj = ViewState["ChangePasswordButtonImageUrl"];
263 return (obj == null) ? String.Empty : (string) obj;
266 ViewState["ChangePasswordButtonImageUrl"] = value;
272 /// Gets the style of change password button.
275 WebCategory("Styles"),
277 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
278 NotifyParentProperty(true),
279 PersistenceMode(PersistenceMode.InnerProperty),
280 WebSysDescription(SR.ChangePassword_ChangePasswordButtonStyle)
282 public Style ChangePasswordButtonStyle {
284 if (_changePasswordButtonStyle == null) {
285 _changePasswordButtonStyle = new Style();
286 if (IsTrackingViewState) {
287 ((IStateManager) _changePasswordButtonStyle).TrackViewState();
290 return _changePasswordButtonStyle;
296 /// Gets or sets the text to be shown for the change password button.
300 WebCategory("Appearance"),
301 WebSysDefaultValue(SR.ChangePassword_DefaultChangePasswordButtonText),
302 WebSysDescription(SR.ChangePassword_ChangePasswordButtonText)
304 public virtual string ChangePasswordButtonText {
306 object obj = ViewState["ChangePasswordButtonText"];
307 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultChangePasswordButtonText) : (string) obj;
310 ViewState["ChangePasswordButtonText"] = value;
316 /// Gets or sets the type of the create user button.
319 WebCategory("Appearance"),
320 DefaultValue(ButtonType.Button),
321 WebSysDescription(SR.ChangePassword_ChangePasswordButtonType)
323 public virtual ButtonType ChangePasswordButtonType {
325 object obj = ViewState["ChangePasswordButtonType"];
326 return (obj == null) ? ButtonType.Button : (ButtonType) obj;
329 if (value < ButtonType.Button || value > ButtonType.Link) {
330 throw new ArgumentOutOfRangeException("value");
332 ViewState["ChangePasswordButtonType"] = value;
338 /// Gets or sets the text to be shown when a change password attempt fails.
342 WebCategory("Appearance"),
343 WebSysDefaultValue(SR.ChangePassword_DefaultChangePasswordFailureText),
344 WebSysDescription(SR.ChangePassword_ChangePasswordFailureText)
346 public virtual string ChangePasswordFailureText {
348 object obj = ViewState["ChangePasswordFailureText"];
349 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultChangePasswordFailureText) : (string) obj;
352 ViewState["ChangePasswordFailureText"] = value;
358 /// Gets or sets the template that is used to render the control. If null, a
359 /// default template is used.
363 PersistenceMode(PersistenceMode.InnerProperty),
364 TemplateContainer(typeof(ChangePassword))
366 public virtual ITemplate ChangePasswordTemplate {
368 return _changePasswordTemplate;
371 _changePasswordTemplate = value;
372 ChildControlsCreated = false;
377 /// Gets the container into which the template is instantiated.
381 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
383 public Control ChangePasswordTemplateContainer {
385 EnsureChildControls();
386 return _changePasswordContainer;
392 /// Gets or sets the title text to be shown for the change password view
396 WebCategory("Appearance"),
397 WebSysDefaultValue(SR.ChangePassword_DefaultChangePasswordTitleText),
398 WebSysDescription(SR.LoginControls_TitleText)
400 public virtual string ChangePasswordTitleText {
402 object obj = ViewState["ChangePasswordTitleText"];
403 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultChangePasswordTitleText) : (string) obj;
406 ViewState["ChangePasswordTitleText"] = value;
412 /// Gets the confirm new password entered by the user.
418 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
420 public virtual string ConfirmNewPassword {
422 return (_confirmNewPassword == null) ? String.Empty : _confirmNewPassword;
428 /// Gets or sets the text that identifies the new password textbox.
432 WebCategory("Appearance"),
433 WebSysDefaultValue(SR.ChangePassword_DefaultConfirmNewPasswordLabelText),
434 WebSysDescription(SR.ChangePassword_ConfirmNewPasswordLabelText)
436 public virtual string ConfirmNewPasswordLabelText {
438 object obj = ViewState["ConfirmNewPasswordLabelText"];
439 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultConfirmNewPasswordLabelText) : (string) obj;
442 ViewState["ConfirmNewPasswordLabelText"] = value;
448 /// Gets or sets the text that is displayed when the new password does not match the confirm password.
452 WebCategory("Validation"),
453 WebSysDefaultValue(SR.ChangePassword_DefaultConfirmPasswordCompareErrorMessage),
454 WebSysDescription(SR.ChangePassword_ConfirmPasswordCompareErrorMessage)
456 public virtual string ConfirmPasswordCompareErrorMessage {
458 object obj = ViewState["ConfirmPasswordCompareErrorMessage"];
459 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultConfirmPasswordCompareErrorMessage) : (string) obj;
462 ViewState["ConfirmPasswordCompareErrorMessage"] = value;
468 /// Gets or sets the text to be shown in the validation summary when the confirm password is empty.
472 WebCategory("Validation"),
473 WebSysDefaultValue(SR.ChangePassword_DefaultConfirmPasswordRequiredErrorMessage),
474 WebSysDescription(SR.LoginControls_ConfirmPasswordRequiredErrorMessage)
476 public virtual string ConfirmPasswordRequiredErrorMessage {
478 object obj = ViewState["ConfirmPasswordRequiredErrorMessage"];
479 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultConfirmPasswordRequiredErrorMessage) : (string) obj;
482 ViewState["ConfirmPasswordRequiredErrorMessage"] = value;
488 /// Gets or sets the URL of an image to be displayed for the continue button.
491 WebCategory("Appearance"),
493 WebSysDescription(SR.ChangePassword_ContinueButtonImageUrl),
494 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
497 public virtual string ContinueButtonImageUrl {
499 object obj = ViewState["ContinueButtonImageUrl"];
500 return (obj == null) ? String.Empty : (string) obj;
503 ViewState["ContinueButtonImageUrl"] = value;
509 /// Gets the style of change password button.
512 WebCategory("Styles"),
514 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
515 NotifyParentProperty(true),
516 PersistenceMode(PersistenceMode.InnerProperty),
517 WebSysDescription(SR.ChangePassword_ContinueButtonStyle)
519 public Style ContinueButtonStyle {
521 if (_continueButtonStyle == null) {
522 _continueButtonStyle = new Style();
523 if (IsTrackingViewState) {
524 ((IStateManager) _continueButtonStyle).TrackViewState();
527 return _continueButtonStyle;
533 /// Gets or sets the text to be shown for the continue button.
537 WebCategory("Appearance"),
538 WebSysDefaultValue(SR.ChangePassword_DefaultContinueButtonText),
539 WebSysDescription(SR.ChangePassword_ContinueButtonText)
541 public virtual string ContinueButtonText {
543 object obj = ViewState["ContinueButtonText"];
544 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultContinueButtonText) : (string) obj;
547 ViewState["ContinueButtonText"] = value;
553 /// Gets or sets the type of the continue button.
556 WebCategory("Appearance"),
557 DefaultValue(ButtonType.Button),
558 WebSysDescription(SR.ChangePassword_ContinueButtonType)
560 public virtual ButtonType ContinueButtonType {
562 object obj = ViewState["ContinueButtonType"];
563 return (obj == null) ? ButtonType.Button : (ButtonType) obj;
566 if (value < ButtonType.Button || value > ButtonType.Link) {
567 throw new ArgumentOutOfRangeException("value");
569 ViewState["ContinueButtonType"] = value;
575 /// Gets or sets the URL for the continue button.
578 WebCategory("Behavior"),
580 WebSysDescription(SR.LoginControls_ContinueDestinationPageUrl),
581 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
585 public virtual string ContinueDestinationPageUrl {
587 object obj = ViewState["ContinueDestinationPageUrl"];
588 return (obj == null) ? String.Empty : (string) obj;
591 ViewState["ContinueDestinationPageUrl"] = value;
595 private bool ConvertingToTemplate {
597 return (DesignMode && _convertingToTemplate);
603 /// Gets or sets the URL of an icon to be displayed for the create user link.
606 WebCategory("Links"),
608 WebSysDescription(SR.ChangePassword_CreateUserIconUrl),
609 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
612 public virtual string CreateUserIconUrl {
614 object obj = ViewState["CreateUserIconUrl"];
615 return (obj == null) ? String.Empty : (string) obj;
618 ViewState["CreateUserIconUrl"] = value;
624 /// Gets or sets the text to be shown for the create user link.
628 WebCategory("Links"),
630 WebSysDescription(SR.ChangePassword_CreateUserText)
632 public virtual string CreateUserText {
634 object obj = ViewState["CreateUserText"];
635 return (obj == null) ? String.Empty : (string) obj;
638 ViewState["CreateUserText"] = value;
644 /// Gets or sets the URL of the create user page.
647 WebCategory("Links"),
649 WebSysDescription(SR.ChangePassword_CreateUserUrl),
650 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
653 public virtual string CreateUserUrl {
655 object obj = ViewState["CreateUserUrl"];
656 return (obj == null) ? String.Empty : (string) obj;
659 ViewState["CreateUserUrl"] = value;
665 /// Gets the current password entered by the user.
671 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
673 public virtual string CurrentPassword {
675 return (_password == null) ? String.Empty : _password;
679 private string CurrentPasswordInternal {
681 string password = CurrentPassword;
682 if (String.IsNullOrEmpty(password) && _changePasswordContainer != null) {
683 ITextControl passwordTextBox = (ITextControl)_changePasswordContainer.CurrentPasswordTextBox;
684 if (passwordTextBox != null) {
685 return passwordTextBox.Text;
693 /// Internal because used from ChangePasswordAdapter.
695 internal View CurrentView {
700 if (value < View.ChangePassword || value > View.Success) {
701 throw new ArgumentOutOfRangeException("value");
703 if (value != CurrentView) {
704 _currentView = value;
711 /// Gets or sets whether the user name is shown
714 WebCategory("Behavior"),
716 WebSysDescription(SR.ChangePassword_DisplayUserName)
718 public virtual bool DisplayUserName {
720 object obj = ViewState["DisplayUserName"];
721 return (obj == null) ? false : (bool) obj;
724 if (DisplayUserName != value) {
725 ViewState["DisplayUserName"] = value;
733 /// Gets or sets the URL for the image shown next to the profile page.
736 WebCategory("Links"),
738 WebSysDescription(SR.LoginControls_EditProfileIconUrl),
739 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
742 public virtual string EditProfileIconUrl {
744 object obj = ViewState["EditProfileIconUrl"];
745 return (obj == null) ? String.Empty : (string) obj;
748 ViewState["EditProfileIconUrl"] = value;
754 /// Gets or sets the text to be shown for the edit profile page
758 WebCategory("Links"),
760 WebSysDescription(SR.ChangePassword_EditProfileText)
762 public virtual string EditProfileText {
764 object obj = ViewState["EditProfileText"];
765 return (obj == null) ? String.Empty : (string) obj;
768 ViewState["EditProfileText"] = value;
774 /// Gets or sets the URL of the edit profile page.
777 WebCategory("Links"),
779 WebSysDescription(SR.ChangePassword_EditProfileUrl),
780 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
783 public virtual string EditProfileUrl {
785 object obj = ViewState["EditProfileUrl"];
786 return (obj == null) ? String.Empty : (string) obj;
789 ViewState["EditProfileUrl"] = value;
795 /// Gets the style of the failure text.
798 WebCategory("Styles"),
800 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
801 NotifyParentProperty(true),
802 PersistenceMode(PersistenceMode.InnerProperty),
803 WebSysDescription(SR.WebControl_FailureTextStyle)
805 public TableItemStyle FailureTextStyle {
807 if (_failureTextStyle == null) {
808 _failureTextStyle = new ErrorTableItemStyle();
809 if (IsTrackingViewState) {
810 ((IStateManager) _failureTextStyle).TrackViewState();
813 return _failureTextStyle;
819 /// Gets or sets the URL of an icon to be displayed for the help link.
822 WebCategory("Links"),
824 WebSysDescription(SR.LoginControls_HelpPageIconUrl),
825 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
828 public virtual string HelpPageIconUrl {
830 object obj = ViewState["HelpPageIconUrl"];
831 return (obj == null) ? String.Empty : (string) obj;
834 ViewState["HelpPageIconUrl"] = value;
840 /// Gets or sets the text to be shown for the help link.
844 WebCategory("Links"),
846 WebSysDescription(SR.ChangePassword_HelpPageText)
848 public virtual string HelpPageText {
850 object obj = ViewState["HelpPageText"];
851 return (obj == null) ? String.Empty : (string) obj;
854 ViewState["HelpPageText"] = value;
860 /// Gets or sets the URL of the help page.
863 WebCategory("Links"),
865 WebSysDescription(SR.LoginControls_HelpPageUrl),
866 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
869 public virtual string HelpPageUrl {
871 object obj = ViewState["HelpPageUrl"];
872 return (obj == null) ? String.Empty : (string) obj;
875 ViewState["HelpPageUrl"] = value;
881 /// Gets the style of the hyperlinks.
884 WebCategory("Styles"),
886 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
887 NotifyParentProperty(true),
888 PersistenceMode(PersistenceMode.InnerProperty),
889 WebSysDescription(SR.WebControl_HyperLinkStyle)
891 public TableItemStyle HyperLinkStyle {
893 if (_hyperLinkStyle == null) {
894 _hyperLinkStyle = new TableItemStyle();
895 if (IsTrackingViewState) {
896 ((IStateManager) _hyperLinkStyle).TrackViewState();
899 return _hyperLinkStyle;
906 /// Gets or sets the text that is displayed to give instructions.
910 WebCategory("Appearance"),
912 WebSysDescription(SR.WebControl_InstructionText)
914 public virtual string InstructionText {
916 object obj = ViewState["InstructionText"];
917 return (obj == null) ? String.Empty : (string) obj;
920 ViewState["InstructionText"] = value;
926 /// Gets the style of the instructions.
929 WebCategory("Styles"),
931 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
932 NotifyParentProperty(true),
933 PersistenceMode(PersistenceMode.InnerProperty),
934 WebSysDescription(SR.WebControl_InstructionTextStyle)
936 public TableItemStyle InstructionTextStyle {
938 if (_instructionTextStyle == null) {
939 _instructionTextStyle = new TableItemStyle();
940 if (IsTrackingViewState) {
941 ((IStateManager) _instructionTextStyle).TrackViewState();
944 return _instructionTextStyle;
950 /// Gets the style of the textbox labels.
953 WebCategory("Styles"),
955 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
956 NotifyParentProperty(true),
957 PersistenceMode(PersistenceMode.InnerProperty),
958 WebSysDescription(SR.LoginControls_LabelStyle)
960 public TableItemStyle LabelStyle {
962 if (_labelStyle == null) {
963 _labelStyle = new TableItemStyle();
964 if (IsTrackingViewState) {
965 ((IStateManager) _labelStyle).TrackViewState();
974 /// Gets or sets the name of the membership provider. If null or empty, the default provider is used.
980 WebSysDescription(SR.MembershipProvider_Name)
982 public virtual string MembershipProvider {
984 object obj = ViewState["MembershipProvider"];
985 return (obj == null) ? String.Empty : (string) obj;
988 ViewState["MembershipProvider"] = value;
995 /// Gets the new password entered by the user.
1001 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
1003 public virtual string NewPassword {
1005 return (_newPassword == null) ? String.Empty : _newPassword;
1009 private string NewPasswordInternal {
1011 string password = NewPassword;
1012 if (String.IsNullOrEmpty(password) && _changePasswordContainer != null) {
1013 ITextControl passwordTextBox = (ITextControl)_changePasswordContainer.NewPasswordTextBox;
1014 if (passwordTextBox != null) {
1015 return passwordTextBox.Text;
1024 /// The text that is displayed when the new password regular expression fails
1027 WebCategory("Validation"),
1028 WebSysDefaultValue(SR.Password_InvalidPasswordErrorMessage),
1029 WebSysDescription(SR.ChangePassword_NewPasswordRegularExpressionErrorMessage)
1031 public virtual string NewPasswordRegularExpressionErrorMessage {
1033 object obj = ViewState["NewPasswordRegularExpressionErrorMessage"];
1034 return (obj == null) ? SR.GetString(SR.Password_InvalidPasswordErrorMessage) : (string) obj;
1037 ViewState["NewPasswordRegularExpressionErrorMessage"] = value;
1043 /// Gets or sets the text that identifies the new password textbox.
1047 WebCategory("Appearance"),
1048 WebSysDefaultValue(SR.ChangePassword_DefaultNewPasswordLabelText),
1049 WebSysDescription(SR.ChangePassword_NewPasswordLabelText)
1051 public virtual string NewPasswordLabelText {
1053 object obj = ViewState["NewPasswordLabelText"];
1054 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultNewPasswordLabelText) : (string) obj;
1057 ViewState["NewPasswordLabelText"] = value;
1063 /// Regular expression used to validate the new password
1066 WebCategory("Validation"),
1067 WebSysDefaultValue(""),
1068 WebSysDescription(SR.ChangePassword_NewPasswordRegularExpression)
1070 public virtual string NewPasswordRegularExpression {
1072 object obj = ViewState["NewPasswordRegularExpression"];
1073 return (obj == null) ? String.Empty : (string) obj;
1076 if (NewPasswordRegularExpression != value) {
1077 ViewState["NewPasswordRegularExpression"] = value;
1085 /// Gets or sets the text to be shown in the validation summary when the new password is empty.
1089 WebCategory("Validation"),
1090 WebSysDefaultValue(SR.ChangePassword_DefaultNewPasswordRequiredErrorMessage),
1091 WebSysDescription(SR.ChangePassword_NewPasswordRequiredErrorMessage)
1093 public virtual string NewPasswordRequiredErrorMessage {
1095 object obj = ViewState["NewPasswordRequiredErrorMessage"];
1096 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultNewPasswordRequiredErrorMessage) : (string) obj;
1099 ViewState["NewPasswordRequiredErrorMessage"] = value;
1105 /// The style of the password hint text.
1108 WebCategory("Styles"),
1110 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1111 NotifyParentProperty(true),
1112 PersistenceMode(PersistenceMode.InnerProperty),
1113 WebSysDescription(SR.ChangePassword_PasswordHintStyle)
1115 public TableItemStyle PasswordHintStyle {
1117 if (_passwordHintStyle == null) {
1118 _passwordHintStyle = new TableItemStyle();
1119 if (IsTrackingViewState) {
1120 ((IStateManager) _passwordHintStyle).TrackViewState();
1123 return _passwordHintStyle;
1129 /// Gets or sets the text to be shown for the password hint.
1133 WebCategory("Appearance"),
1135 WebSysDescription(SR.ChangePassword_PasswordHintText)
1137 public virtual string PasswordHintText {
1139 object obj = ViewState["PasswordHintText"];
1140 return (obj == null) ? String.Empty : (string) obj;
1143 ViewState["PasswordHintText"] = value;
1150 /// Gets or sets the text that identifies the password textbox.
1154 WebCategory("Appearance"),
1155 WebSysDefaultValue(SR.LoginControls_DefaultPasswordLabelText),
1156 WebSysDescription(SR.LoginControls_PasswordLabelText)
1158 public virtual string PasswordLabelText {
1160 object obj = ViewState["PasswordLabelText"];
1161 return (obj == null) ? SR.GetString(SR.LoginControls_DefaultPasswordLabelText) : (string) obj;
1164 ViewState["PasswordLabelText"] = value;
1170 /// Gets or sets the URL of an icon to be displayed for the password recovery link.
1173 WebCategory("Links"),
1175 WebSysDescription(SR.ChangePassword_PasswordRecoveryIconUrl),
1176 Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
1179 public virtual string PasswordRecoveryIconUrl {
1181 object obj = ViewState["PasswordRecoveryIconUrl"];
1182 return (obj == null) ? String.Empty : (string) obj;
1185 ViewState["PasswordRecoveryIconUrl"] = value;
1191 /// Gets or sets the text to be shown for the password recovery link.
1195 WebCategory("Links"),
1197 WebSysDescription(SR.ChangePassword_PasswordRecoveryText)
1199 public virtual string PasswordRecoveryText {
1201 object obj = ViewState["PasswordRecoveryText"];
1202 return (obj == null) ? String.Empty : (string) obj;
1205 ViewState["PasswordRecoveryText"] = value;
1211 /// Gets or sets the URL of the password recovery page.
1214 WebCategory("Links"),
1216 WebSysDescription(SR.ChangePassword_PasswordRecoveryUrl),
1217 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
1220 public virtual string PasswordRecoveryUrl {
1222 object obj = ViewState["PasswordRecoveryUrl"];
1223 return (obj == null) ? String.Empty : (string) obj;
1226 ViewState["PasswordRecoveryUrl"] = value;
1232 /// Gets or sets the text to be shown in the validation summary when the password is empty.
1236 WebCategory("Validation"),
1237 WebSysDefaultValue(SR.ChangePassword_DefaultPasswordRequiredErrorMessage),
1238 WebSysDescription(SR.ChangePassword_PasswordRequiredErrorMessage)
1240 public virtual string PasswordRequiredErrorMessage {
1242 object obj = ViewState["PasswordRequiredErrorMessage"];
1243 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultPasswordRequiredErrorMessage) : (string) obj;
1246 ViewState["PasswordRequiredErrorMessage"] = value;
1251 /// Determines whether we create the regular expression validator
1253 private bool RegExpEnabled {
1255 return (NewPasswordRegularExpression.Length > 0);
1261 /// The content and format of the e-mail message that contains a successful change password notification.
1264 WebCategory("Behavior"),
1265 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1266 NotifyParentProperty(true),
1267 PersistenceMode(PersistenceMode.InnerProperty),
1269 WebSysDescription(SR.ChangePassword_MailDefinition)
1271 public MailDefinition MailDefinition {
1273 if (_mailDefinition == null) {
1274 _mailDefinition = new MailDefinition();
1275 if (IsTrackingViewState) {
1276 ((IStateManager) _mailDefinition).TrackViewState();
1279 return _mailDefinition;
1284 WebCategory("Layout"),
1286 WebSysDescription(SR.LoginControls_RenderOuterTable),
1287 SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces",
1288 Justification = "Interface denotes existence of property, not used for security.")
1290 public virtual bool RenderOuterTable {
1292 object obj = ViewState["RenderOuterTable"];
1293 return (obj == null) ? true : (bool)obj;
1296 ViewState["RenderOuterTable"] = value;
1301 /// The URL that the user is directed to after the password has been changed.
1302 /// If non-null, always redirect the user to this page after successful password change. Else, perform the refresh action.
1305 WebCategory("Behavior"),
1307 WebSysDescription(SR.LoginControls_SuccessPageUrl),
1308 Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
1312 public virtual string SuccessPageUrl {
1314 object obj = ViewState["SuccessPageUrl"];
1315 return (obj == null) ? String.Empty : (string) obj;
1318 ViewState["SuccessPageUrl"] = value;
1324 /// Template rendered after the password has been changed.
1328 PersistenceMode(PersistenceMode.InnerProperty),
1329 TemplateContainer(typeof(ChangePassword))
1331 public virtual ITemplate SuccessTemplate {
1333 return _successTemplate;
1336 _successTemplate = value;
1337 ChildControlsCreated = false;
1342 /// Internal because used from ChangePasswordAdapter.
1346 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
1348 public Control SuccessTemplateContainer {
1350 EnsureChildControls();
1351 return _successContainer;
1357 /// The text to be shown after the password has been changed.
1361 WebCategory("Appearance"),
1362 WebSysDefaultValue(SR.ChangePassword_DefaultSuccessText),
1363 WebSysDescription(SR.ChangePassword_SuccessText)
1365 public virtual string SuccessText {
1367 object obj = ViewState["SuccessText"];
1368 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultSuccessText) : (string) obj;
1371 ViewState["SuccessText"] = value;
1379 /// The style of the success text.
1382 WebCategory("Styles"),
1384 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1385 NotifyParentProperty(true),
1386 PersistenceMode(PersistenceMode.InnerProperty),
1387 WebSysDescription(SR.ChangePassword_SuccessTextStyle)
1389 public TableItemStyle SuccessTextStyle {
1391 if (_successTextStyle == null) {
1392 _successTextStyle = new TableItemStyle();
1393 if (IsTrackingViewState) {
1394 ((IStateManager) _successTextStyle).TrackViewState();
1397 return _successTextStyle;
1403 /// Gets or sets the title text to be shown for success
1407 WebCategory("Appearance"),
1408 WebSysDefaultValue(SR.ChangePassword_DefaultSuccessTitleText),
1409 WebSysDescription(SR.ChangePassword_SuccessTitleText)
1411 public virtual string SuccessTitleText {
1413 object obj = ViewState["SuccessTitleText"];
1414 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultSuccessTitleText) : (string) obj;
1417 ViewState["SuccessTitleText"] = value;
1421 protected override HtmlTextWriterTag TagKey {
1423 return HtmlTextWriterTag.Table;
1429 /// Gets or sets the style of the textboxes.
1432 WebCategory("Styles"),
1434 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1435 NotifyParentProperty(true),
1436 PersistenceMode(PersistenceMode.InnerProperty),
1437 WebSysDescription(SR.LoginControls_TextBoxStyle)
1439 public Style TextBoxStyle {
1441 if (_textBoxStyle == null) {
1442 _textBoxStyle = new Style();
1443 if (IsTrackingViewState) {
1444 ((IStateManager) _textBoxStyle).TrackViewState();
1447 return _textBoxStyle;
1453 /// Gets the style of the title.
1456 WebCategory("Styles"),
1458 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1459 NotifyParentProperty(true),
1460 PersistenceMode(PersistenceMode.InnerProperty),
1461 WebSysDescription(SR.LoginControls_TitleTextStyle)
1463 public TableItemStyle TitleTextStyle {
1465 if (_titleTextStyle == null) {
1466 _titleTextStyle = new TableItemStyle();
1467 if (IsTrackingViewState) {
1468 ((IStateManager) _titleTextStyle).TrackViewState();
1471 return _titleTextStyle;
1477 /// Gets or sets the initial value in the user name textbox.
1480 WebCategory("Appearance"),
1482 WebSysDescription(SR.UserName_InitialValue)
1484 public virtual string UserName {
1486 return (_userName == null) ? String.Empty : _userName;
1493 private string UserNameInternal {
1495 string userName = UserName;
1496 if (String.IsNullOrEmpty(userName) && _changePasswordContainer != null && DisplayUserName) {
1497 ITextControl userTextBox = (ITextControl)_changePasswordContainer.UserNameTextBox;
1498 if (userTextBox != null) {
1499 return userTextBox.Text;
1508 /// Gets or sets the text that identifies the user name textbox.
1512 WebCategory("Appearance"),
1513 WebSysDefaultValue(SR.ChangePassword_DefaultUserNameLabelText),
1514 WebSysDescription(SR.LoginControls_UserNameLabelText)
1516 public virtual string UserNameLabelText {
1518 object obj = ViewState["UserNameLabelText"];
1519 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultUserNameLabelText) : (string) obj;
1522 ViewState["UserNameLabelText"] = value;
1530 /// Gets or sets the text to be shown in the validation summary when the user name is empty.
1534 WebCategory("Validation"),
1535 WebSysDefaultValue(SR.ChangePassword_DefaultUserNameRequiredErrorMessage),
1536 WebSysDescription(SR.ChangePassword_UserNameRequiredErrorMessage)
1538 public virtual string UserNameRequiredErrorMessage {
1540 object obj = ViewState["UserNameRequiredErrorMessage"];
1541 return (obj == null) ? SR.GetString(SR.ChangePassword_DefaultUserNameRequiredErrorMessage) : (string) obj;
1544 ViewState["UserNameRequiredErrorMessage"] = value;
1548 internal Control ValidatorRow {
1550 return _validatorRow;
1553 _validatorRow = value;
1558 WebCategory("Styles"),
1560 DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1561 NotifyParentProperty(true),
1562 PersistenceMode(PersistenceMode.InnerProperty),
1563 WebSysDescription(SR.ChangePassword_ValidatorTextStyle)
1565 public Style ValidatorTextStyle {
1567 if (_validatorTextStyle == null) {
1568 _validatorTextStyle = new ErrorStyle();
1569 if (IsTrackingViewState) {
1570 ((IStateManager) _validatorTextStyle).TrackViewState();
1573 return _validatorTextStyle;
1577 ///////////////////// EVENTS //////////////////////////////
1581 /// Raised on the click of the cancel button.
1584 WebCategory("Action"),
1585 WebSysDescription(SR.ChangePassword_CancelButtonClick)
1587 public event EventHandler CancelButtonClick {
1589 Events.AddHandler(EventCancelButtonClick, value);
1592 Events.RemoveHandler(EventCancelButtonClick, value);
1598 /// Raised after the password has been changed successfully.
1601 WebCategory("Action"),
1602 WebSysDescription(SR.ChangePassword_ChangedPassword)
1604 public event EventHandler ChangedPassword {
1606 Events.AddHandler(EventChangedPassword, value);
1609 Events.RemoveHandler(EventChangedPassword, value);
1615 /// Raised if the change password attempt fails.
1618 WebCategory("Action"),
1619 WebSysDescription(SR.ChangePassword_ChangePasswordError)
1621 public event EventHandler ChangePasswordError {
1623 Events.AddHandler(EventChangePasswordError, value);
1626 Events.RemoveHandler(EventChangePasswordError, value);
1632 /// Raised before changing the password.
1635 WebCategory("Action"),
1636 WebSysDescription(SR.ChangePassword_ChangingPassword)
1638 public event LoginCancelEventHandler ChangingPassword {
1640 Events.AddHandler(EventChangingPassword, value);
1643 Events.RemoveHandler(EventChangingPassword, value);
1649 /// Raised on the click of the continue button.
1652 WebCategory("Action"),
1653 WebSysDescription(SR.ChangePassword_ContinueButtonClick)
1655 public event EventHandler ContinueButtonClick {
1657 Events.AddHandler(EventContinueButtonClick, value);
1660 Events.RemoveHandler(EventContinueButtonClick, value);
1666 /// Raised before the e-mail is sent.
1669 WebCategory("Action"),
1670 WebSysDescription(SR.ChangePassword_SendingMail)
1672 public event MailMessageEventHandler SendingMail {
1674 Events.AddHandler(EventSendingMail, value);
1677 Events.RemoveHandler(EventSendingMail, value);
1683 /// Raised when there is an error sending mail.
1686 WebCategory("Action"),
1687 WebSysDescription(SR.ChangePassword_SendMailError)
1689 public event SendMailErrorEventHandler SendMailError {
1691 Events.AddHandler(EventSendMailError, value);
1694 Events.RemoveHandler(EventSendMailError, value);
1699 /// Attempts to change the password for the user.
1700 /// Raises appropriate events along the way for login, changing password, mail.
1702 private void AttemptChangePassword() {
1703 if (Page != null && !Page.IsValid) {
1707 LoginCancelEventArgs cancelArgs = new LoginCancelEventArgs();
1708 OnChangingPassword(cancelArgs);
1709 if (cancelArgs.Cancel) {
1713 MembershipProvider provider = LoginUtil.GetProvider(MembershipProvider);
1714 MembershipUser user = provider.GetUser(UserNameInternal, /*userIsOnline*/ false, /*throwOnError*/ false);
1715 string newPassword = NewPasswordInternal;
1716 if (user != null && user.ChangePassword(CurrentPasswordInternal, newPassword, /*throwOnError*/ false)) {
1717 // Only log the user in if approved and not locked out
1718 if (user.IsApproved && !user.IsLockedOut) {
1719 System.Web.Security.FormsAuthentication.SetAuthCookie(UserNameInternal, false);
1722 OnChangedPassword(EventArgs.Empty);
1723 PerformSuccessAction(user.Email, user.UserName, newPassword);
1726 OnChangePasswordError(EventArgs.Empty);
1727 string failureText = ChangePasswordFailureText;
1728 if (!String.IsNullOrEmpty(failureText)) {
1729 failureText = String.Format(CultureInfo.CurrentCulture, failureText, provider.MinRequiredPasswordLength,
1730 provider.MinRequiredNonAlphanumericCharacters);
1732 SetFailureTextLabel(_changePasswordContainer, failureText);
1736 private void ConfirmNewPasswordTextChanged(object source, EventArgs e) {
1737 _confirmNewPassword = ((ITextControl) source).Text;
1741 /// Creates the controls needed for the change password view
1743 private void CreateChangePasswordViewControls() {
1744 _changePasswordContainer = new ChangePasswordContainer(this);
1745 _changePasswordContainer.ID = _changePasswordViewContainerID;
1746 _changePasswordContainer.RenderDesignerRegion = _renderDesignerRegion;
1748 ITemplate template = ChangePasswordTemplate;
1749 bool defaultTemplate = (template == null);
1750 if (defaultTemplate) {
1751 // Only disable viewstate if using default template
1752 _changePasswordContainer.EnableViewState = false;
1754 // Disable theming if using default template (VSWhidbey 86010)
1755 _changePasswordContainer.EnableTheming = false;
1757 template = new DefaultChangePasswordTemplate(this);
1760 template.InstantiateIn(_changePasswordContainer);
1761 Controls.Add(_changePasswordContainer);
1763 IEditableTextControl userNameTextBox = _changePasswordContainer.UserNameTextBox as IEditableTextControl;
1764 if (userNameTextBox != null) {
1765 userNameTextBox.TextChanged += new EventHandler(UserNameTextChanged);
1768 IEditableTextControl passwordTextBox = _changePasswordContainer.CurrentPasswordTextBox as IEditableTextControl;
1769 if (passwordTextBox != null) {
1770 passwordTextBox.TextChanged += new EventHandler(PasswordTextChanged);
1773 IEditableTextControl newPasswordTextBox = _changePasswordContainer.NewPasswordTextBox as IEditableTextControl;
1774 if (newPasswordTextBox != null) {
1775 newPasswordTextBox.TextChanged += new EventHandler(NewPasswordTextChanged);
1778 IEditableTextControl confirmNewPasswordTextBox = _changePasswordContainer.ConfirmNewPasswordTextBox as IEditableTextControl;
1779 if (confirmNewPasswordTextBox != null) {
1780 confirmNewPasswordTextBox.TextChanged += new EventHandler(ConfirmNewPasswordTextChanged);
1783 // Set the editable child control properties here for two reasons:
1784 // - So change events will be raised if viewstate is disabled on the child controls
1785 // - Viewstate is always disabled for default template, and might be for user template
1786 // - So the controls render correctly in the designer
1787 SetEditableChildProperties();
1792 /// Instantiates the template in the template container, and wires up necessary events.
1794 protected internal override void CreateChildControls() {
1797 CreateChangePasswordViewControls();
1798 CreateSuccessViewControls();
1802 private void CreateSuccessViewControls() {
1803 ITemplate template = null;
1804 _successContainer = new SuccessContainer(this);
1805 _successContainer.ID = _successViewContainerID;
1806 _successContainer.RenderDesignerRegion = _renderDesignerRegion;
1807 if (SuccessTemplate != null) {
1808 template = SuccessTemplate;
1812 template = new DefaultSuccessTemplate(this);
1813 _successContainer.EnableViewState = false;
1815 // Disable theming if using default template (VSWhidbey 86010)
1816 _successContainer.EnableTheming = false;
1818 template.InstantiateIn(_successContainer);
1819 Controls.Add(_successContainer);
1823 /// Loads the control state for those properties that should persist across postbacks
1824 /// even when EnableViewState=false.
1826 protected internal override void LoadControlState(object savedState) {
1827 if (savedState != null) {
1828 Triplet state = (Triplet)savedState;
1829 if (state.First != null) {
1830 base.LoadControlState(state.First);
1832 if (state.Second != null) {
1833 _currentView = (View)(int)state.Second;
1835 if (state.Third != null) {
1836 _userName = (string)state.Third;
1844 /// Loads a saved state of the <see cref='System.Web.UI.WebControls.ChangePassword'/>.
1846 protected override void LoadViewState(object savedState) {
1847 if (savedState == null) {
1848 base.LoadViewState(null);
1851 object[] myState = (object[]) savedState;
1852 if (myState.Length != _viewStateArrayLength) {
1853 throw new ArgumentException(SR.GetString(SR.ViewState_InvalidViewState));
1856 base.LoadViewState(myState[0]);
1857 if (myState[1] != null) {
1858 ((IStateManager) ChangePasswordButtonStyle).LoadViewState(myState[1]);
1860 if (myState[2] != null) {
1861 ((IStateManager) LabelStyle).LoadViewState(myState[2]);
1863 if (myState[3] != null) {
1864 ((IStateManager) TextBoxStyle).LoadViewState(myState[3]);
1866 if (myState[4] != null) {
1867 ((IStateManager) HyperLinkStyle).LoadViewState(myState[4]);
1869 if (myState[5] != null) {
1870 ((IStateManager) InstructionTextStyle).LoadViewState(myState[5]);
1872 if (myState[6] != null) {
1873 ((IStateManager) TitleTextStyle).LoadViewState(myState[6]);
1875 if (myState[7] != null) {
1876 ((IStateManager) PasswordHintStyle).LoadViewState(myState[7]);
1878 if (myState[8] != null) {
1879 ((IStateManager) FailureTextStyle).LoadViewState(myState[8]);
1881 if (myState[9] != null) {
1882 ((IStateManager) MailDefinition).LoadViewState(myState[9]);
1884 if (myState[10] != null) {
1885 ((IStateManager) CancelButtonStyle).LoadViewState(myState[10]);
1887 if (myState[11] != null) {
1888 ((IStateManager) ContinueButtonStyle).LoadViewState(myState[11]);
1890 if (myState[12] != null) {
1891 ((IStateManager) SuccessTextStyle).LoadViewState(myState[12]);
1893 if (myState[13] != null) {
1894 ((IStateManager) ValidatorTextStyle).LoadViewState(myState[13]);
1901 private void NewPasswordTextChanged(object source, EventArgs e) {
1902 _newPassword = ((ITextControl) source).Text;
1907 /// Called when an event is raised by a control inside our template. Attempts to login
1908 /// if the event was raised by the submit button.
1910 protected override bool OnBubbleEvent(object source, EventArgs e) {
1911 bool handled = false;
1912 if (e is CommandEventArgs) {
1913 CommandEventArgs ce = (CommandEventArgs) e;
1914 if (ce.CommandName.Equals(ChangePasswordButtonCommandName, StringComparison.CurrentCultureIgnoreCase)) {
1915 AttemptChangePassword();
1918 else if (ce.CommandName.Equals(CancelButtonCommandName, StringComparison.CurrentCultureIgnoreCase)) {
1919 OnCancelButtonClick(ce);
1922 else if (ce.CommandName.Equals(ContinueButtonCommandName, StringComparison.CurrentCultureIgnoreCase)) {
1923 OnContinueButtonClick(ce);
1932 /// Raises the CancelClick event.
1934 protected virtual void OnCancelButtonClick(EventArgs e) {
1935 EventHandler handler = (EventHandler)Events[EventCancelButtonClick];
1936 if (handler != null) {
1940 string cancelPageUrl = CancelDestinationPageUrl;
1941 if (!String.IsNullOrEmpty(cancelPageUrl)) {
1942 // Microsoft suggested that we should not terminate execution of current page, to give
1943 // page a chance to cleanup its resources. This may be less performant though.
1944 // Microsoft suggested that we need to call ResolveClientUrl before redirecting.
1945 // Example is this control inside user control, want redirect relative to user control dir.
1946 Page.Response.Redirect(ResolveClientUrl(cancelPageUrl), false);
1952 /// Raises the ChangedPassword event.
1954 protected virtual void OnChangedPassword(EventArgs e) {
1955 EventHandler handler = (EventHandler)Events[EventChangedPassword];
1956 if (handler != null) {
1963 /// Raises the ChangePasswordError event.
1965 protected virtual void OnChangePasswordError(EventArgs e) {
1966 EventHandler handler = (EventHandler)Events[EventChangePasswordError];
1967 if (handler != null) {
1974 /// Raises the ChangingPassword event.
1976 protected virtual void OnChangingPassword(LoginCancelEventArgs e) {
1977 LoginCancelEventHandler handler = (LoginCancelEventHandler)Events[EventChangingPassword];
1978 if (handler != null) {
1985 /// Raises the ContinueButtonClick event.
1987 protected virtual void OnContinueButtonClick(EventArgs e) {
1988 EventHandler handler = (EventHandler)Events[EventContinueButtonClick];
1989 if (handler != null) {
1993 string continuePageUrl = ContinueDestinationPageUrl;
1994 if (!String.IsNullOrEmpty(continuePageUrl)) {
1996 // Microsoft suggested that we should not terminate execution of current page, to give
1997 // page a chance to cleanup its resources. This may be less performant though.
1998 // Microsoft suggested that we need to call ResolveClientUrl before redirecting.
1999 // Example is this control inside user control, want redirect relative to user control dir.
2000 Page.Response.Redirect(ResolveClientUrl(continuePageUrl), false);
2005 protected internal override void OnInit(EventArgs e) {
2006 // Fill in the User name if authenticated
2008 string userName = LoginUtil.GetUserName(this);
2009 if (!String.IsNullOrEmpty(userName)) {
2010 UserName = userName;
2015 Page.RegisterRequiresControlState(this);
2020 /// Overridden to set the editable child control properteries and hide the control when appropriate.
2022 protected internal override void OnPreRender(EventArgs e) {
2023 base.OnPreRender(e);
2025 // Set the editable child control properties here instead of Render, so they get into viewstate for the user template.
2026 switch (CurrentView) {
2027 case View.ChangePassword:
2028 SetEditableChildProperties();
2035 /// Raises the SendingMail event.
2037 protected virtual void OnSendingMail(MailMessageEventArgs e) {
2038 MailMessageEventHandler handler = (MailMessageEventHandler)Events[EventSendingMail];
2039 if (handler != null) {
2046 /// Raises the SendMailError event.
2048 protected virtual void OnSendMailError(SendMailErrorEventArgs e) {
2049 SendMailErrorEventHandler handler = (SendMailErrorEventHandler)Events[EventSendMailError];
2050 if (handler != null) {
2055 private void PasswordTextChanged(object source, EventArgs e) {
2056 _password = ((ITextControl) source).Text;
2059 private void PerformSuccessAction(string email, string userName, string newPassword) {
2060 // Try to send mail only if a MailDefinition is specified for success,
2061 // and the user has an email address.
2062 if (_mailDefinition != null && !String.IsNullOrEmpty(email)) {
2063 LoginUtil.SendPasswordMail(email, userName, newPassword, MailDefinition, /*defaultSubject*/ null,
2064 /*defaultBody*/ null, OnSendingMail, OnSendMailError, this);
2067 string successPageUrl = SuccessPageUrl;
2068 if (!String.IsNullOrEmpty(successPageUrl)) {
2069 // Microsoft suggested that we should not terminate execution of current page, to give
2070 // page a chance to cleanup its resources. This may be less performant though.
2071 // Microsoft suggested that we need to call ResolveClientUrl before redirecting.
2072 // Example is this control inside user control, want redirect relative to user control dir.
2073 Page.Response.Redirect(ResolveClientUrl(successPageUrl), false);
2076 CurrentView = View.Success;
2082 /// Adds the ClientID and renders contents, because we don't want the outer <span>.
2084 protected internal override void Render(HtmlTextWriter writer) {
2086 Page.VerifyRenderingInServerForm(this);
2089 // Copied from CompositeControl.cs
2091 ChildControlsCreated = false;
2093 EnsureChildControls();
2095 SetChildProperties();
2096 RenderContents(writer);
2101 /// Saves the control state for those properties that should persist across postbacks
2102 /// even when EnableViewState=false.
2104 protected internal override object SaveControlState() {
2105 object baseState = base.SaveControlState();
2107 // Save the int value of the enum (instead of the enum value itself)
2108 // to save space in ControlState
2109 object currentViewState = null;
2110 object userNameState = null;
2112 currentViewState = (int)_currentView;
2114 // Don't save _userName once we have reached the success view (VSWhidbey 81327)
2115 if (_userName != null && _currentView != View.Success) {
2116 userNameState = _userName;
2118 return new Triplet(baseState, currentViewState, userNameState);
2124 /// Saves the state of the <see cref='System.Web.UI.WebControls.ChangePassword'/>.
2126 protected override object SaveViewState() {
2127 object[] myState = new object[_viewStateArrayLength];
2129 myState[0] = base.SaveViewState();
2130 myState[1] = (_changePasswordButtonStyle != null) ? ((IStateManager)_changePasswordButtonStyle).SaveViewState() : null;
2131 myState[2] = (_labelStyle != null) ? ((IStateManager)_labelStyle).SaveViewState() : null;
2132 myState[3] = (_textBoxStyle != null) ? ((IStateManager)_textBoxStyle).SaveViewState() : null;
2133 myState[4] = (_hyperLinkStyle != null) ? ((IStateManager)_hyperLinkStyle).SaveViewState() : null;
2135 (_instructionTextStyle != null) ? ((IStateManager)_instructionTextStyle).SaveViewState() : null;
2136 myState[6] = (_titleTextStyle != null) ? ((IStateManager)_titleTextStyle).SaveViewState() : null;
2137 myState[7] = (_passwordHintStyle != null) ? ((IStateManager)_passwordHintStyle).SaveViewState() : null;
2139 (_failureTextStyle != null) ? ((IStateManager)_failureTextStyle).SaveViewState() : null;
2140 myState[9] = (_mailDefinition != null) ? ((IStateManager)_mailDefinition).SaveViewState() : null;
2141 myState[10] = (_cancelButtonStyle != null) ? ((IStateManager)_cancelButtonStyle).SaveViewState() : null;
2142 myState[11] = (_continueButtonStyle != null) ? ((IStateManager)_continueButtonStyle).SaveViewState() : null;
2143 myState[12] = (_successTextStyle != null) ? ((IStateManager)_successTextStyle).SaveViewState() : null;
2144 myState[13] = (_validatorTextStyle != null) ? ((IStateManager)_validatorTextStyle).SaveViewState() : null;
2146 for (int i=0; i < _viewStateArrayLength; i++) {
2147 if (myState[i] != null) {
2152 // More performant to return null than an array of null values
2157 /// Used frequently, so extracted into method.
2159 private void SetFailureTextLabel(ChangePasswordContainer container, string failureText) {
2160 ITextControl failureTextLabel = (ITextControl)container.FailureTextLabel;
2161 if (failureTextLabel != null) {
2162 failureTextLabel.Text = failureText;
2167 /// Internal for access from LoginAdapter
2169 internal void SetChildProperties() {
2170 switch (CurrentView) {
2171 case View.ChangePassword:
2172 SetCommonChangePasswordViewProperties();
2173 if (ChangePasswordTemplate == null) {
2174 SetDefaultChangePasswordViewProperties();
2178 SetCommonSuccessViewProperties();
2179 if (SuccessTemplate == null) {
2180 SetDefaultSuccessViewProperties();
2187 /// Sets change password view control properties that apply to both default and user templates.
2189 private void SetCommonChangePasswordViewProperties() {
2190 // Clear out the access key/tab index so it doesn't get applied to the tables in the container
2191 Util.CopyBaseAttributesToInnerControl(this, _changePasswordContainer);
2193 _changePasswordContainer.ApplyStyle(ControlStyle);
2194 _successContainer.Visible = false;
2198 /// Sets success view control properties that apply to both default and user templates.
2200 private void SetCommonSuccessViewProperties() {
2201 // Clear out the tab index so it doesn't get applied to the tables in the container
2202 Util.CopyBaseAttributesToInnerControl(this, _successContainer);
2204 _successContainer.ApplyStyle(ControlStyle);
2205 _changePasswordContainer.Visible = false;
2211 /// Allows the designer to set the CurrentView, so the different templates can be shown in the designer.
2213 [SecurityPermission(SecurityAction.Demand, Unrestricted = true)]
2214 protected override void SetDesignModeState(IDictionary data) {
2216 object o = data["CurrentView"];
2218 CurrentView = (View)o;
2220 o = data["ConvertToTemplate"];
2222 _convertingToTemplate = (bool)o;
2224 o = data["RegionEditing"];
2226 _renderDesignerRegion = (bool)o;
2233 /// Sets child control properties that apply only to the default template.
2235 private void SetDefaultChangePasswordViewProperties() {
2236 ChangePasswordContainer container = _changePasswordContainer;
2238 // Need to set the BorderPadding on the BorderTable instead of the LayoutTable, since
2239 // setting it on the LayoutTable would cause all of the controls inside the Login to be
2240 // separated by the BorderPadding amount.
2241 container.BorderTable.CellPadding = BorderPadding;
2242 container.BorderTable.CellSpacing = 0;
2244 LoginUtil.ApplyStyleToLiteral(container.Title, ChangePasswordTitleText, TitleTextStyle, true);
2245 LoginUtil.ApplyStyleToLiteral(container.Instruction, InstructionText, InstructionTextStyle, true);
2246 LoginUtil.ApplyStyleToLiteral(container.UserNameLabel, UserNameLabelText, LabelStyle, false);
2247 LoginUtil.ApplyStyleToLiteral(container.CurrentPasswordLabel, PasswordLabelText, LabelStyle, false);
2248 LoginUtil.ApplyStyleToLiteral(container.NewPasswordLabel, NewPasswordLabelText, LabelStyle, false);
2249 LoginUtil.ApplyStyleToLiteral(container.ConfirmNewPasswordLabel, ConfirmNewPasswordLabelText, LabelStyle, false);
2250 LoginUtil.ApplyStyleToLiteral(container.PasswordHintLabel, PasswordHintText, PasswordHintStyle, false);
2252 // Apply style to all the text boxes if necessary
2253 if (_textBoxStyle != null) {
2254 if (DisplayUserName) ((WebControl)container.UserNameTextBox).ApplyStyle(TextBoxStyle);
2255 ((WebControl)container.CurrentPasswordTextBox).ApplyStyle(TextBoxStyle);
2256 ((WebControl)container.NewPasswordTextBox).ApplyStyle(TextBoxStyle);
2257 ((WebControl)container.ConfirmNewPasswordTextBox).ApplyStyle(TextBoxStyle);
2260 _passwordHintTableRow.Visible = !String.IsNullOrEmpty(PasswordHintText);
2261 _userNameTableRow.Visible = DisplayUserName;
2264 if (DisplayUserName) {
2265 ((WebControl)container.UserNameTextBox).TabIndex = TabIndex;
2266 ((WebControl)container.UserNameTextBox).AccessKey = AccessKey;
2268 ((WebControl)container.CurrentPasswordTextBox).AccessKey = AccessKey;
2270 ((WebControl)container.CurrentPasswordTextBox).TabIndex = TabIndex;
2271 ((WebControl)container.NewPasswordTextBox).TabIndex = TabIndex;
2272 ((WebControl)container.ConfirmNewPasswordTextBox).TabIndex = TabIndex;
2275 bool enableValidation = true;
2276 ValidatorRow.Visible = enableValidation;
2278 RequiredFieldValidator userNameRequired = container.UserNameRequired;
2279 userNameRequired.ErrorMessage = UserNameRequiredErrorMessage;
2280 userNameRequired.ToolTip = UserNameRequiredErrorMessage;
2281 userNameRequired.Enabled = enableValidation;
2282 userNameRequired.Visible = enableValidation;
2283 if (_validatorTextStyle != null) {
2284 userNameRequired.ApplyStyle(_validatorTextStyle);
2287 RequiredFieldValidator passwordRequired = container.PasswordRequired;
2288 passwordRequired.ErrorMessage = PasswordRequiredErrorMessage;
2289 passwordRequired.ToolTip = PasswordRequiredErrorMessage;
2290 passwordRequired.Enabled = enableValidation;
2291 passwordRequired.Visible = enableValidation;
2293 RequiredFieldValidator newPasswordRequired = container.NewPasswordRequired;
2294 newPasswordRequired.ErrorMessage = NewPasswordRequiredErrorMessage;
2295 newPasswordRequired.ToolTip = NewPasswordRequiredErrorMessage;
2296 newPasswordRequired.Enabled = enableValidation;
2297 newPasswordRequired.Visible = enableValidation;
2299 RequiredFieldValidator confirmNewPasswordRequired = container.ConfirmNewPasswordRequired;
2300 confirmNewPasswordRequired.ErrorMessage = ConfirmPasswordRequiredErrorMessage;
2301 confirmNewPasswordRequired.ToolTip = ConfirmPasswordRequiredErrorMessage;
2302 confirmNewPasswordRequired.Enabled = enableValidation;
2303 confirmNewPasswordRequired.Visible = enableValidation;
2305 CompareValidator newPasswordCompareValidator = container.NewPasswordCompareValidator;
2306 newPasswordCompareValidator.ErrorMessage = ConfirmPasswordCompareErrorMessage;
2307 newPasswordCompareValidator.Enabled = enableValidation;
2308 newPasswordCompareValidator.Visible = enableValidation;
2310 if (_validatorTextStyle != null) {
2311 passwordRequired.ApplyStyle(_validatorTextStyle);
2312 newPasswordRequired.ApplyStyle(_validatorTextStyle);
2313 confirmNewPasswordRequired.ApplyStyle(_validatorTextStyle);
2314 newPasswordCompareValidator.ApplyStyle(_validatorTextStyle);
2317 RegularExpressionValidator regExpValidator = container.RegExpValidator;
2318 regExpValidator.ErrorMessage = NewPasswordRegularExpressionErrorMessage;
2319 regExpValidator.Enabled = enableValidation;
2320 regExpValidator.Visible = enableValidation;
2321 if (_validatorTextStyle != null) {
2322 regExpValidator.ApplyStyle(_validatorTextStyle);
2326 LinkButton linkButton = container.ChangePasswordLinkButton;
2327 LinkButton cancelLinkButton = container.CancelLinkButton;
2328 ImageButton imageButton = container.ChangePasswordImageButton;
2329 ImageButton cancelImageButton = container.CancelImageButton;
2330 Button pushButton = container.ChangePasswordPushButton;
2331 Button cancelPushButton = container.CancelPushButton;
2333 WebControl changePasswordButton = null;
2334 WebControl cancelButton = null;
2335 switch (CancelButtonType) {
2336 case ButtonType.Link:
2337 cancelLinkButton.Text = CancelButtonText;
2338 cancelButton = cancelLinkButton;
2340 case ButtonType.Image:
2341 cancelImageButton.ImageUrl = CancelButtonImageUrl;
2342 cancelImageButton.AlternateText = CancelButtonText;
2343 cancelButton = cancelImageButton;
2345 case ButtonType.Button:
2346 cancelPushButton.Text = CancelButtonText;
2347 cancelButton = cancelPushButton;
2350 switch (ChangePasswordButtonType) {
2351 case ButtonType.Link:
2352 linkButton.Text = ChangePasswordButtonText;
2353 changePasswordButton = linkButton;
2355 case ButtonType.Image:
2356 imageButton.ImageUrl = ChangePasswordButtonImageUrl;
2357 imageButton.AlternateText = ChangePasswordButtonText;
2358 changePasswordButton = imageButton;
2360 case ButtonType.Button:
2361 pushButton.Text = ChangePasswordButtonText;
2362 changePasswordButton = pushButton;
2366 // Set all buttons to nonvisible, then set the selected button to visible
2367 linkButton.Visible = false;
2368 imageButton.Visible = false;
2369 pushButton.Visible = false;
2370 cancelLinkButton.Visible = false;
2371 cancelImageButton.Visible = false;
2372 cancelPushButton.Visible = false;
2373 changePasswordButton.Visible = true;
2374 cancelButton.Visible = true;
2375 cancelButton.TabIndex = TabIndex;
2376 changePasswordButton.TabIndex = TabIndex;
2378 if (CancelButtonStyle != null) cancelButton.ApplyStyle(CancelButtonStyle);
2379 if (ChangePasswordButtonStyle != null) changePasswordButton.ApplyStyle(ChangePasswordButtonStyle);
2382 Image createUserIcon = container.CreateUserIcon;
2383 HyperLink createUserLink = container.CreateUserLink;
2384 LiteralControl createUserLinkSeparator = container.CreateUserLinkSeparator;
2385 HyperLink passwordRecoveryLink = container.PasswordRecoveryLink;
2386 Image passwordRecoveryIcon = container.PasswordRecoveryIcon;
2387 HyperLink helpPageLink = container.HelpPageLink;
2388 Image helpPageIcon = container.HelpPageIcon;
2389 LiteralControl helpPageLinkSeparator = container.HelpPageLinkSeparator;
2390 LiteralControl editProfileLinkSeparator = container.EditProfileLinkSeparator;
2391 HyperLink editProfileLink = container.EditProfileLink;
2392 Image editProfileIcon = container.EditProfileIcon;
2393 string createUserText = CreateUserText;
2394 string createUserIconUrl = CreateUserIconUrl;
2395 string passwordRecoveryText = PasswordRecoveryText;
2396 string passwordRecoveryIconUrl = PasswordRecoveryIconUrl;
2397 string helpPageText = HelpPageText;
2398 string helpPageIconUrl = HelpPageIconUrl;
2399 string editProfileText = EditProfileText;
2400 string editProfileIconUrl = EditProfileIconUrl;
2401 bool createUserTextVisible = (createUserText.Length > 0);
2402 bool passwordRecoveryTextVisible = (passwordRecoveryText.Length > 0);
2403 bool helpPageTextVisible = (helpPageText.Length > 0);
2404 bool helpPageIconVisible = (helpPageIconUrl.Length > 0);
2405 bool createUserIconVisible = (createUserIconUrl.Length > 0);
2406 bool passwordRecoveryIconVisible = (passwordRecoveryIconUrl.Length > 0);
2407 bool helpPageLineVisible = helpPageTextVisible || helpPageIconVisible;
2408 bool createUserLineVisible = createUserTextVisible || createUserIconVisible;
2409 bool passwordRecoveryLineVisible = passwordRecoveryTextVisible || passwordRecoveryIconVisible;
2410 bool editProfileTextVisible = (editProfileText.Length > 0);
2411 bool editProfileIconVisible = (editProfileIconUrl.Length > 0);
2412 bool editProfileLineVisible = (editProfileTextVisible || editProfileIconVisible);
2414 helpPageLink.Visible = helpPageTextVisible;
2415 helpPageLinkSeparator.Visible = helpPageLineVisible && (passwordRecoveryLineVisible || createUserLineVisible || editProfileLineVisible);
2416 if (helpPageTextVisible) {
2417 helpPageLink.Text = helpPageText;
2418 helpPageLink.NavigateUrl = HelpPageUrl;
2419 helpPageLink.TabIndex = TabIndex;
2421 helpPageIcon.Visible = helpPageIconVisible;
2422 if (helpPageIconVisible) {
2423 helpPageIcon.ImageUrl = helpPageIconUrl;
2424 helpPageIcon.AlternateText = HelpPageText;
2427 createUserLink.Visible = createUserTextVisible;
2428 createUserLinkSeparator.Visible = (createUserLineVisible && (passwordRecoveryLineVisible || editProfileLineVisible));
2429 if (createUserTextVisible) {
2430 createUserLink.Text = createUserText;
2431 createUserLink.NavigateUrl = CreateUserUrl;
2432 createUserLink.TabIndex = TabIndex;
2434 createUserIcon.Visible = createUserIconVisible;
2435 if (createUserIconVisible) {
2436 createUserIcon.ImageUrl = createUserIconUrl;
2437 createUserIcon.AlternateText = CreateUserText;
2440 passwordRecoveryLink.Visible = passwordRecoveryTextVisible;
2441 if (passwordRecoveryTextVisible) {
2442 passwordRecoveryLink.Text = passwordRecoveryText;
2443 passwordRecoveryLink.NavigateUrl = PasswordRecoveryUrl;
2444 passwordRecoveryLink.TabIndex = TabIndex;
2446 passwordRecoveryIcon.Visible = passwordRecoveryIconVisible;
2447 if (passwordRecoveryIconVisible) {
2448 passwordRecoveryIcon.ImageUrl = passwordRecoveryIconUrl;
2449 passwordRecoveryIcon.AlternateText = PasswordRecoveryText;
2451 editProfileLinkSeparator.Visible = (passwordRecoveryLineVisible && editProfileLineVisible);
2453 editProfileLink.Visible = editProfileTextVisible;
2454 editProfileIcon.Visible = editProfileIconVisible;
2455 if (editProfileTextVisible) {
2456 editProfileLink.Text = editProfileText;
2457 editProfileLink.NavigateUrl = EditProfileUrl;
2458 editProfileLink.TabIndex = TabIndex;
2460 if (editProfileIconVisible) {
2461 editProfileIcon.ImageUrl = editProfileIconUrl;
2462 editProfileIcon.AlternateText = EditProfileText;
2465 if (createUserLineVisible || passwordRecoveryLineVisible || helpPageLineVisible || editProfileLineVisible) {
2466 if (_hyperLinkStyle != null) {
2467 // Apply style except font to table cell, then apply font and forecolor to HyperLinks
2469 TableItemStyle hyperLinkStyleExceptFont = new TableItemStyle();
2470 hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
2471 hyperLinkStyleExceptFont.Font.Reset();
2472 LoginUtil.SetTableCellStyle(createUserLink, hyperLinkStyleExceptFont);
2473 createUserLink.Font.CopyFrom(_hyperLinkStyle.Font);
2474 createUserLink.ForeColor = _hyperLinkStyle.ForeColor;
2475 passwordRecoveryLink.Font.CopyFrom(_hyperLinkStyle.Font);
2476 passwordRecoveryLink.ForeColor = _hyperLinkStyle.ForeColor;
2477 helpPageLink.Font.CopyFrom(_hyperLinkStyle.Font);
2478 helpPageLink.ForeColor = _hyperLinkStyle.ForeColor;
2479 editProfileLink.Font.CopyFrom(_hyperLinkStyle.Font);
2480 editProfileLink.ForeColor = _hyperLinkStyle.ForeColor;
2482 LoginUtil.SetTableCellVisible(helpPageLink, true);
2485 LoginUtil.SetTableCellVisible(helpPageLink, false);
2488 Control failureTextLabel = container.FailureTextLabel;
2489 if (((ITextControl)failureTextLabel).Text.Length > 0) {
2490 LoginUtil.SetTableCellStyle(failureTextLabel, FailureTextStyle);
2491 LoginUtil.SetTableCellVisible(failureTextLabel, true);
2494 LoginUtil.SetTableCellVisible(failureTextLabel, false);
2499 /// Internal because called from ChangePasswordAdapter.
2501 internal void SetDefaultSuccessViewProperties() {
2502 SuccessContainer container = _successContainer;
2503 LinkButton linkButton = container.ContinueLinkButton;
2504 ImageButton imageButton = container.ContinueImageButton;
2505 Button pushButton = container.ContinuePushButton;
2507 container.BorderTable.CellPadding = BorderPadding;
2508 container.BorderTable.CellSpacing = 0;
2510 WebControl button = null;
2511 switch (ContinueButtonType) {
2512 case ButtonType.Link:
2513 linkButton.Text = ContinueButtonText;
2514 button = linkButton;
2516 case ButtonType.Image:
2517 imageButton.ImageUrl = ContinueButtonImageUrl;
2518 imageButton.AlternateText = ContinueButtonText;
2519 button = imageButton;
2521 case ButtonType.Button:
2522 pushButton.Text = ContinueButtonText;
2523 button = pushButton;
2527 linkButton.Visible = false;
2528 imageButton.Visible = false;
2529 pushButton.Visible = false;
2530 button.Visible = true;
2531 button.TabIndex = TabIndex;
2532 button.AccessKey = AccessKey;
2534 if (ContinueButtonStyle != null) button.ApplyStyle(ContinueButtonStyle);
2536 LoginUtil.ApplyStyleToLiteral(container.Title, SuccessTitleText, _titleTextStyle, true);
2537 LoginUtil.ApplyStyleToLiteral(container.SuccessTextLabel, SuccessText, _successTextStyle, true);
2539 string editProfileText = EditProfileText;
2540 string editProfileIconUrl = EditProfileIconUrl;
2541 bool editProfileVisible = (editProfileText.Length > 0);
2542 bool editProfileIconVisible = (editProfileIconUrl.Length > 0);
2543 HyperLink editProfileLink = container.EditProfileLink;
2544 Image editProfileIcon = container.EditProfileIcon;
2545 editProfileIcon.Visible = editProfileIconVisible;
2546 editProfileLink.Visible = editProfileVisible;
2547 if (editProfileVisible) {
2548 editProfileLink.Text = editProfileText;
2549 editProfileLink.NavigateUrl = EditProfileUrl;
2550 editProfileLink.TabIndex = TabIndex;
2551 if (_hyperLinkStyle != null) {
2552 // Apply style except font to table cell, then apply font and forecolor to HyperLinks
2554 Style hyperLinkStyleExceptFont = new TableItemStyle();
2555 hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
2556 hyperLinkStyleExceptFont.Font.Reset();
2557 LoginUtil.SetTableCellStyle(editProfileLink, hyperLinkStyleExceptFont);
2558 editProfileLink.Font.CopyFrom(_hyperLinkStyle.Font);
2559 editProfileLink.ForeColor = _hyperLinkStyle.ForeColor;
2562 if (editProfileIconVisible) {
2563 editProfileIcon.ImageUrl = editProfileIconUrl;
2564 editProfileIcon.AlternateText = EditProfileText;
2566 LoginUtil.SetTableCellVisible(editProfileLink, editProfileVisible || editProfileIconVisible);
2570 /// Sets the properties of child controls that are editable by the client.
2572 private void SetEditableChildProperties() {
2573 // We need to use UserNameInternal for the DropDownList case where it won't fire a TextChanged for the first item
2574 if (UserNameInternal.Length > 0 && DisplayUserName) {
2575 ITextControl userNameTextBox = (ITextControl)_changePasswordContainer.UserNameTextBox;
2576 if (userNameTextBox != null) {
2577 userNameTextBox.Text = UserNameInternal;
2583 /// Marks the starting point to begin tracking and saving changes to the
2584 /// control as part of the control viewstate.
2586 protected override void TrackViewState() {
2587 base.TrackViewState();
2589 if (_changePasswordButtonStyle != null) {
2590 ((IStateManager) _changePasswordButtonStyle).TrackViewState();
2592 if (_labelStyle != null) {
2593 ((IStateManager) _labelStyle).TrackViewState();
2595 if (_textBoxStyle != null) {
2596 ((IStateManager) _textBoxStyle).TrackViewState();
2598 if (_successTextStyle != null) {
2599 ((IStateManager) _successTextStyle).TrackViewState();
2601 if (_hyperLinkStyle != null) {
2602 ((IStateManager) _hyperLinkStyle).TrackViewState();
2604 if (_instructionTextStyle != null) {
2605 ((IStateManager) _instructionTextStyle).TrackViewState();
2607 if (_titleTextStyle != null) {
2608 ((IStateManager) _titleTextStyle).TrackViewState();
2610 if (_passwordHintStyle != null) {
2611 ((IStateManager) _passwordHintStyle).TrackViewState();
2613 if (_failureTextStyle != null) {
2614 ((IStateManager) _failureTextStyle).TrackViewState();
2616 if (_mailDefinition != null) {
2617 ((IStateManager) _mailDefinition).TrackViewState();
2619 if (_cancelButtonStyle != null) {
2620 ((IStateManager) _cancelButtonStyle).TrackViewState();
2622 if (_continueButtonStyle != null) {
2623 ((IStateManager) _continueButtonStyle).TrackViewState();
2625 if (_validatorTextStyle != null) {
2626 ((IStateManager) _validatorTextStyle).TrackViewState();
2630 private void UpdateValidators() {
2635 ChangePasswordContainer container = _changePasswordContainer;
2637 if (container != null) {
2638 bool displayUserName = DisplayUserName;
2639 RequiredFieldValidator userNameRequired = container.UserNameRequired;
2640 if (userNameRequired != null) {
2641 userNameRequired.Enabled = displayUserName;
2642 userNameRequired.Visible = displayUserName;
2645 bool regExpEnabled = RegExpEnabled;
2646 RegularExpressionValidator regExpValidator = container.RegExpValidator;
2647 if (regExpValidator != null) {
2648 regExpValidator.Enabled = regExpEnabled;
2649 regExpValidator.Visible = regExpEnabled;
2654 private void UserNameTextChanged(object source, EventArgs e) {
2655 string userName = ((ITextControl) source).Text;
2656 if (!String.IsNullOrEmpty(userName)) {
2657 UserName = userName;
2662 /// The default success template for the control, used if SuccessTemplate is null.
2664 private sealed class DefaultSuccessTemplate : ITemplate {
2665 private ChangePassword _owner;
2667 public DefaultSuccessTemplate(ChangePassword owner) {
2671 private void CreateControls(SuccessContainer successContainer) {
2672 successContainer.Title = new Literal();
2673 successContainer.SuccessTextLabel = new Literal();
2674 successContainer.EditProfileLink = new HyperLink();
2675 successContainer.EditProfileLink.ID = _editProfileSuccessLinkID;
2676 successContainer.EditProfileIcon = new Image();
2678 LinkButton linkButton = new LinkButton();
2679 linkButton.ID = _continueLinkButtonID;
2680 linkButton.CommandName = ContinueButtonCommandName;
2681 linkButton.CausesValidation = false;
2682 successContainer.ContinueLinkButton = linkButton;
2684 ImageButton imageButton = new ImageButton();
2685 imageButton.ID = _continueImageButtonID;
2686 imageButton.CommandName = ContinueButtonCommandName;
2687 imageButton.CausesValidation = false;
2688 successContainer.ContinueImageButton = imageButton;
2690 Button pushButton = new Button();
2691 pushButton.ID = _continuePushButtonID;
2692 pushButton.CommandName = ContinueButtonCommandName;
2693 pushButton.CausesValidation = false;
2694 successContainer.ContinuePushButton = pushButton;
2697 private void LayoutControls(SuccessContainer successContainer) {
2698 Table table = new Table();
2699 table.CellPadding = 0;
2703 r = new LoginUtil.DisappearingTableRow();
2704 c = new TableCell();
2706 c.HorizontalAlign = HorizontalAlign.Center;
2707 c.Controls.Add(successContainer.Title);
2711 r = new LoginUtil.DisappearingTableRow();
2712 c = new TableCell();
2713 c.Controls.Add(successContainer.SuccessTextLabel);
2717 r = new LoginUtil.DisappearingTableRow();
2718 c = new TableCell();
2720 c.HorizontalAlign = HorizontalAlign.Right;
2721 c.Controls.Add(successContainer.ContinuePushButton);
2722 c.Controls.Add(successContainer.ContinueLinkButton);
2723 c.Controls.Add(successContainer.ContinueImageButton);
2727 r = new LoginUtil.DisappearingTableRow();
2728 c = new TableCell();
2730 c.Controls.Add(successContainer.EditProfileIcon);
2731 c.Controls.Add(successContainer.EditProfileLink);
2735 Table table2 = LoginUtil.CreateChildTable(_owner.ConvertingToTemplate);
2737 c = new TableCell();
2738 c.Controls.Add(table);
2742 successContainer.LayoutTable = table;
2743 successContainer.BorderTable = table2;
2744 successContainer.Controls.Add(table2);
2747 void ITemplate.InstantiateIn(Control container) {
2748 SuccessContainer successContainer = (SuccessContainer) container;
2749 CreateControls(successContainer);
2750 LayoutControls(successContainer);
2755 /// Container for the success template.
2756 /// Internal instead of private because it must be used by ChangePasswordAdapter.
2758 internal sealed class SuccessContainer : LoginUtil.GenericContainer<ChangePassword>, INonBindingContainer {
2759 private Literal _successTextLabel;
2760 private Button _continuePushButton;
2761 private LinkButton _continueLinkButton;
2762 private ImageButton _continueImageButton;
2763 private Image _editProfileIcon;
2764 private HyperLink _editProfileLink;
2765 private Literal _title;
2767 public SuccessContainer(ChangePassword owner) : base(owner) {
2770 internal ImageButton ContinueImageButton {
2772 return _continueImageButton;
2775 _continueImageButton = value;
2779 internal LinkButton ContinueLinkButton {
2781 return _continueLinkButton;
2784 _continueLinkButton = value;
2788 internal Button ContinuePushButton {
2790 return _continuePushButton;
2793 _continuePushButton = value;
2797 protected override bool ConvertingToTemplate {
2799 return Owner.ConvertingToTemplate;
2803 internal Image EditProfileIcon {
2805 return _editProfileIcon;
2808 _editProfileIcon = value;
2812 internal HyperLink EditProfileLink {
2814 return _editProfileLink;
2817 _editProfileLink = value;
2821 public Literal SuccessTextLabel {
2823 return _successTextLabel;
2826 _successTextLabel = value;
2830 internal Literal Title {
2841 /// The default template for the control, used if ChangePasswordTemplate is null.
2843 private sealed class DefaultChangePasswordTemplate : ITemplate {
2844 private ChangePassword _owner;
2846 public DefaultChangePasswordTemplate(ChangePassword owner) {
2851 /// Helper function to create and set properties for a required field validator
2853 private RequiredFieldValidator CreateRequiredFieldValidator(string id, TextBox textBox, string validationGroup, bool enableValidation) {
2854 RequiredFieldValidator validator = new RequiredFieldValidator();
2856 validator.ValidationGroup = validationGroup;
2857 validator.ControlToValidate = textBox.ID;
2858 validator.Display = _requiredFieldValidatorDisplay;
2859 validator.Text = SR.GetString(SR.LoginControls_DefaultRequiredFieldValidatorText);
2860 validator.Enabled = enableValidation;
2861 validator.Visible = enableValidation;
2866 /// Creates the child controls, sets certain properties (mostly static properties)
2868 private void CreateControls(ChangePasswordContainer container) {
2869 string validationGroup = _owner.UniqueID;
2871 container.Title = new Literal();
2872 container.Instruction = new Literal();
2873 container.PasswordHintLabel = new Literal();
2875 TextBox userNameTextBox = new TextBox();
2876 // Must explicitly set the ID of controls that raise postback events
2877 userNameTextBox.ID = _userNameID;
2878 container.UserNameTextBox = userNameTextBox;
2879 container.UserNameLabel = new LabelLiteral(userNameTextBox);
2881 bool enableValidation = (_owner.CurrentView == View.ChangePassword);
2883 container.UserNameRequired = CreateRequiredFieldValidator(_userNameRequiredID, userNameTextBox, validationGroup, enableValidation);
2885 TextBox currentPasswordTextBox = new TextBox();
2886 // Must explicitly set the ID of controls that raise postback events
2887 currentPasswordTextBox.ID = _currentPasswordID;
2888 currentPasswordTextBox.TextMode = TextBoxMode.Password;
2889 container.CurrentPasswordTextBox = currentPasswordTextBox;
2890 container.CurrentPasswordLabel = new LabelLiteral(currentPasswordTextBox);
2892 container.PasswordRequired = CreateRequiredFieldValidator(_currentPasswordRequiredID, currentPasswordTextBox, validationGroup, enableValidation);
2894 TextBox newPasswordTextBox = new TextBox();
2895 // Must explicitly set the ID of controls that raise postback events
2896 newPasswordTextBox.ID = _newPasswordID;
2897 newPasswordTextBox.TextMode = TextBoxMode.Password;
2898 container.NewPasswordTextBox = newPasswordTextBox;
2899 container.NewPasswordLabel = new LabelLiteral(newPasswordTextBox);
2901 container.NewPasswordRequired = CreateRequiredFieldValidator(_newPasswordRequiredID, newPasswordTextBox, validationGroup, enableValidation);
2903 TextBox confirmNewPasswordTextBox = new TextBox();
2904 // Must explicitly set the ID of controls that raise postback events
2905 confirmNewPasswordTextBox.ID = _confirmNewPasswordID;
2906 confirmNewPasswordTextBox.TextMode = TextBoxMode.Password;
2907 container.ConfirmNewPasswordTextBox = confirmNewPasswordTextBox;
2908 container.ConfirmNewPasswordLabel = new LabelLiteral(confirmNewPasswordTextBox);
2910 container.ConfirmNewPasswordRequired = CreateRequiredFieldValidator(_confirmNewPasswordRequiredID, confirmNewPasswordTextBox, validationGroup, enableValidation);
2912 // Setup compare validator for new/confirmNewPassword values
2913 CompareValidator compareValidator = new CompareValidator();
2914 compareValidator.ID = _newPasswordCompareID;
2915 compareValidator.ValidationGroup = validationGroup;
2916 compareValidator.ControlToValidate = _confirmNewPasswordID;
2917 compareValidator.ControlToCompare = _newPasswordID;
2918 compareValidator.Operator = ValidationCompareOperator.Equal;
2919 compareValidator.ErrorMessage = _owner.ConfirmPasswordCompareErrorMessage;
2920 compareValidator.Display = _compareFieldValidatorDisplay;
2921 compareValidator.Enabled = enableValidation;
2922 compareValidator.Visible = enableValidation;
2923 container.NewPasswordCompareValidator = compareValidator;
2925 // Reg exp validator
2926 RegularExpressionValidator regExpValidator = new RegularExpressionValidator();
2927 regExpValidator.ID = _newPasswordRegExpID;
2928 regExpValidator.ValidationGroup = validationGroup;
2929 regExpValidator.ControlToValidate = _newPasswordID;
2930 regExpValidator.ErrorMessage = _owner.NewPasswordRegularExpressionErrorMessage;
2931 regExpValidator.ValidationExpression = _owner.NewPasswordRegularExpression;
2932 regExpValidator.Display = _regexpFieldValidatorDisplay;
2933 regExpValidator.Enabled = enableValidation;
2934 regExpValidator.Visible = enableValidation;
2935 container.RegExpValidator = regExpValidator;
2938 LinkButton linkButton = new LinkButton();
2939 linkButton.ID = _changePasswordLinkButtonID;
2940 linkButton.ValidationGroup = validationGroup;
2941 linkButton.CommandName = ChangePasswordButtonCommandName;
2942 container.ChangePasswordLinkButton = linkButton;
2944 linkButton = new LinkButton();
2945 linkButton.ID = _cancelLinkButtonID;
2946 linkButton.CausesValidation = false;
2947 linkButton.CommandName = CancelButtonCommandName;
2948 container.CancelLinkButton = linkButton;
2950 ImageButton imageButton = new ImageButton();
2951 imageButton.ID = _changePasswordImageButtonID;
2952 imageButton.ValidationGroup = validationGroup;
2953 imageButton.CommandName = ChangePasswordButtonCommandName;
2954 container.ChangePasswordImageButton = imageButton;
2956 imageButton = new ImageButton();
2957 imageButton.ID = _cancelImageButtonID;
2958 imageButton.CommandName = CancelButtonCommandName;
2959 imageButton.CausesValidation = false;
2960 container.CancelImageButton = imageButton;
2962 Button pushButton = new Button();
2963 pushButton.ID = _changePasswordPushButtonID;
2964 pushButton.ValidationGroup = validationGroup;
2965 pushButton.CommandName = ChangePasswordButtonCommandName;
2966 container.ChangePasswordPushButton = pushButton;
2968 pushButton = new Button();
2969 pushButton.ID = _cancelPushButtonID;
2970 pushButton.CommandName = CancelButtonCommandName;
2971 pushButton.CausesValidation = false;
2972 container.CancelPushButton = pushButton;
2974 container.PasswordRecoveryIcon = new Image();
2975 container.PasswordRecoveryLink = new HyperLink();
2976 container.PasswordRecoveryLink.ID = _passwordRecoveryLinkID;
2978 container.CreateUserIcon = new Image();
2979 container.CreateUserLink = new HyperLink();
2980 container.CreateUserLink.ID = _createUserLinkID;
2981 container.CreateUserLinkSeparator = new LiteralControl();
2983 container.HelpPageIcon = new Image();
2984 container.HelpPageLink = new HyperLink();
2985 container.HelpPageLink.ID = _helpLinkID;
2986 container.HelpPageLinkSeparator = new LiteralControl();
2988 container.EditProfileLink = new HyperLink();
2989 container.EditProfileLink.ID = _editProfileLinkID;
2990 container.EditProfileIcon = new Image();
2991 container.EditProfileLinkSeparator = new LiteralControl();
2993 Literal failureTextLabel = new Literal();
2994 failureTextLabel.ID = _failureTextID;
2995 container.FailureTextLabel = failureTextLabel;
2999 /// Adds the controls to a table for layout. Layout depends on TextLayout properties.
3001 private void LayoutControls(ChangePasswordContainer container) {
3002 Table table = new Table();
3003 table.CellPadding = 0;
3007 r = new LoginUtil.DisappearingTableRow();
3008 c = new TableCell();
3010 c.HorizontalAlign = HorizontalAlign.Center;
3011 c.Controls.Add(container.Title);
3015 r = new LoginUtil.DisappearingTableRow();
3016 c = new TableCell();
3018 c.HorizontalAlign = HorizontalAlign.Center;
3019 c.Controls.Add(container.Instruction);
3023 // UserName is only visible if enabled
3024 r = new LoginUtil.DisappearingTableRow();
3025 c = new TableCell();
3026 c.HorizontalAlign = HorizontalAlign.Right;
3027 if (_owner.ConvertingToTemplate) {
3028 container.UserNameLabel.RenderAsLabel = true;
3030 c.Controls.Add(container.UserNameLabel);
3033 c = new TableCell();
3034 c.Controls.Add(container.UserNameTextBox);
3035 c.Controls.Add(container.UserNameRequired);
3038 _owner._userNameTableRow = r;
3040 r = new LoginUtil.DisappearingTableRow();
3041 c = new TableCell();
3042 c.HorizontalAlign = HorizontalAlign.Right;
3043 c.Controls.Add(container.CurrentPasswordLabel);
3044 if (_owner.ConvertingToTemplate) {
3045 container.CurrentPasswordLabel.RenderAsLabel = true;
3049 c = new TableCell();
3050 c.Controls.Add(container.CurrentPasswordTextBox);
3051 c.Controls.Add(container.PasswordRequired);
3055 r = new LoginUtil.DisappearingTableRow();
3056 c = new TableCell();
3057 c.HorizontalAlign = HorizontalAlign.Right;
3058 c.Controls.Add(container.NewPasswordLabel);
3059 if (_owner.ConvertingToTemplate) {
3060 container.NewPasswordLabel.RenderAsLabel = true;
3064 c = new TableCell();
3065 c.Controls.Add(container.NewPasswordTextBox);
3066 c.Controls.Add(container.NewPasswordRequired);
3070 r = new LoginUtil.DisappearingTableRow();
3071 c = new TableCell();
3073 c = new TableCell();
3074 c.Controls.Add(container.PasswordHintLabel);
3077 _owner._passwordHintTableRow = r;
3079 r = new LoginUtil.DisappearingTableRow();
3080 c = new TableCell();
3081 c.HorizontalAlign = HorizontalAlign.Right;
3082 c.Controls.Add(container.ConfirmNewPasswordLabel);
3083 if (_owner.ConvertingToTemplate) {
3084 container.ConfirmNewPasswordLabel.RenderAsLabel = true;
3088 c = new TableCell();
3089 c.Controls.Add(container.ConfirmNewPasswordTextBox);
3090 c.Controls.Add(container.ConfirmNewPasswordRequired);
3094 r = new LoginUtil.DisappearingTableRow();
3095 c = new TableCell();
3096 c.HorizontalAlign = HorizontalAlign.Center;
3098 c.Controls.Add(container.NewPasswordCompareValidator);
3102 if (_owner.RegExpEnabled) {
3103 r = new LoginUtil.DisappearingTableRow();
3104 c = new TableCell();
3105 c.HorizontalAlign = HorizontalAlign.Center;
3107 c.Controls.Add(container.RegExpValidator);
3111 _owner.ValidatorRow = r;
3113 r = new LoginUtil.DisappearingTableRow();
3114 c = new TableCell();
3115 c.HorizontalAlign = HorizontalAlign.Center;
3117 c.Controls.Add(container.FailureTextLabel);
3121 r = new LoginUtil.DisappearingTableRow();
3122 c = new TableCell();
3123 c.HorizontalAlign = HorizontalAlign.Right;
3124 c.Controls.Add(container.ChangePasswordLinkButton);
3125 c.Controls.Add(container.ChangePasswordImageButton);
3126 c.Controls.Add(container.ChangePasswordPushButton);
3128 c = new TableCell();
3129 c.Controls.Add(container.CancelLinkButton);
3130 c.Controls.Add(container.CancelImageButton);
3131 c.Controls.Add(container.CancelPushButton);
3135 r = new LoginUtil.DisappearingTableRow();
3136 c = new TableCell();
3138 c.Controls.Add(container.HelpPageIcon);
3139 c.Controls.Add(container.HelpPageLink);
3140 c.Controls.Add(container.HelpPageLinkSeparator);
3141 c.Controls.Add(container.CreateUserIcon);
3142 c.Controls.Add(container.CreateUserLink);
3143 container.HelpPageLinkSeparator.Text = "<br />";
3144 container.CreateUserLinkSeparator.Text = "<br />";
3145 container.EditProfileLinkSeparator.Text = "<br />";
3146 c.Controls.Add(container.CreateUserLinkSeparator);
3147 c.Controls.Add(container.PasswordRecoveryIcon);
3148 c.Controls.Add(container.PasswordRecoveryLink);
3149 c.Controls.Add(container.EditProfileLinkSeparator);
3150 c.Controls.Add(container.EditProfileIcon);
3151 c.Controls.Add(container.EditProfileLink);
3155 Table table2 = LoginUtil.CreateChildTable(_owner.ConvertingToTemplate);
3157 c = new TableCell();
3158 c.Controls.Add(table);
3162 container.LayoutTable = table;
3163 container.BorderTable = table2;
3164 container.Controls.Add(table2);
3167 #region ITemplate implementation
3168 void ITemplate.InstantiateIn(Control container) {
3169 ChangePasswordContainer cpContainer = (ChangePasswordContainer) container;
3170 CreateControls(cpContainer);
3171 LayoutControls(cpContainer);
3177 /// Container for the layout template. Contains properties that reference each child control.
3178 /// For the default template, the properties are set when the child controls are created.
3179 /// For the user template, the controls are looked up dynamically by ID. Some controls are required,
3180 /// and an exception is thrown if they are missing. Other controls are optional, and an exception is
3181 /// thrown if they have the wrong type.
3182 /// Internal instead of private because it must be used by LoginAdapter.
3184 internal sealed class ChangePasswordContainer : LoginUtil.GenericContainer<ChangePassword>, INonBindingContainer {
3185 private LiteralControl _createUserLinkSeparator;
3186 private LiteralControl _helpPageLinkSeparator;
3187 private LiteralControl _editProfileLinkSeparator;
3188 private Control _failureTextLabel;
3189 private ImageButton _changePasswordImageButton;
3190 private LinkButton _changePasswordLinkButton;
3191 private Button _changePasswordPushButton;
3192 private ImageButton _cancelImageButton;
3193 private LinkButton _cancelLinkButton;
3194 private Button _cancelPushButton;
3196 private Image _createUserIcon;
3197 private Image _helpPageIcon;
3198 private Image _passwordRecoveryIcon;
3199 private Image _editProfileIcon;
3201 private RequiredFieldValidator _passwordRequired;
3202 private RequiredFieldValidator _userNameRequired;
3203 private RequiredFieldValidator _confirmNewPasswordRequired;
3204 private RequiredFieldValidator _newPasswordRequired;
3205 private CompareValidator _newPasswordCompareValidator;
3206 private RegularExpressionValidator _regExpValidator;
3208 private Literal _title;
3209 private Literal _instruction;
3210 private LabelLiteral _userNameLabel;
3211 private LabelLiteral _currentPasswordLabel;
3212 private LabelLiteral _newPasswordLabel;
3213 private LabelLiteral _confirmNewPasswordLabel;
3214 private Literal _passwordHintLabel;
3215 private Control _userNameTextBox;
3216 private Control _currentPasswordTextBox;
3217 private Control _newPasswordTextBox;
3218 private Control _confirmNewPasswordTextBox;
3219 private HyperLink _helpPageLink;
3220 private HyperLink _passwordRecoveryLink;
3221 private HyperLink _createUserLink;
3222 private HyperLink _editProfileLink;
3224 public ChangePasswordContainer(ChangePassword owner) : base(owner) {
3227 internal ImageButton CancelImageButton {
3229 return _cancelImageButton;
3232 _cancelImageButton = value;
3236 internal LinkButton CancelLinkButton {
3238 return _cancelLinkButton;
3241 _cancelLinkButton = value;
3245 internal Button CancelPushButton {
3247 return _cancelPushButton;
3250 _cancelPushButton = value;
3254 internal ImageButton ChangePasswordImageButton {
3256 return _changePasswordImageButton;
3259 _changePasswordImageButton = value;
3263 internal LinkButton ChangePasswordLinkButton {
3265 return _changePasswordLinkButton;
3268 _changePasswordLinkButton = value;
3272 internal Button ChangePasswordPushButton {
3274 return _changePasswordPushButton;
3277 _changePasswordPushButton = value;
3281 internal LabelLiteral ConfirmNewPasswordLabel {
3283 return _confirmNewPasswordLabel;
3286 _confirmNewPasswordLabel = value;
3290 internal RequiredFieldValidator ConfirmNewPasswordRequired {
3292 return _confirmNewPasswordRequired;
3296 _confirmNewPasswordRequired = value;
3300 internal Control ConfirmNewPasswordTextBox {
3302 if (_confirmNewPasswordTextBox != null) {
3303 return _confirmNewPasswordTextBox;
3306 return FindOptionalControl<IEditableTextControl>(_confirmNewPasswordID);
3310 _confirmNewPasswordTextBox = value;
3314 protected override bool ConvertingToTemplate {
3316 return Owner.ConvertingToTemplate;
3320 internal Image CreateUserIcon {
3322 return _createUserIcon;
3325 _createUserIcon = value;
3329 internal HyperLink CreateUserLink {
3331 return _createUserLink;
3334 _createUserLink = value;
3338 internal LiteralControl CreateUserLinkSeparator {
3340 return _createUserLinkSeparator;
3343 _createUserLinkSeparator = value;
3347 internal LabelLiteral CurrentPasswordLabel {
3349 return _currentPasswordLabel;
3352 _currentPasswordLabel = value;
3356 internal Control CurrentPasswordTextBox {
3358 if (_currentPasswordTextBox != null) {
3359 return _currentPasswordTextBox;
3362 return FindRequiredControl<IEditableTextControl>(_currentPasswordID,
3363 SR.ChangePassword_NoCurrentPasswordTextBox);
3367 _currentPasswordTextBox = value;
3371 internal Image EditProfileIcon {
3373 return _editProfileIcon;
3376 _editProfileIcon = value;
3380 internal HyperLink EditProfileLink {
3382 return _editProfileLink;
3385 _editProfileLink = value;
3389 internal LiteralControl EditProfileLinkSeparator {
3391 return _editProfileLinkSeparator;
3394 _editProfileLinkSeparator = value;
3398 internal Control FailureTextLabel {
3400 if (_failureTextLabel != null) {
3401 return _failureTextLabel;
3404 return FindOptionalControl<ITextControl>(_failureTextID);
3408 _failureTextLabel = value;
3412 internal Image HelpPageIcon {
3414 return _helpPageIcon;
3417 _helpPageIcon = value;
3421 internal HyperLink HelpPageLink {
3423 return _helpPageLink;
3426 _helpPageLink = value;
3430 internal LiteralControl HelpPageLinkSeparator {
3432 return _helpPageLinkSeparator;
3435 _helpPageLinkSeparator = value;
3439 internal Literal Instruction {
3441 return _instruction;
3444 _instruction = value;
3448 internal CompareValidator NewPasswordCompareValidator {
3450 return _newPasswordCompareValidator;
3453 _newPasswordCompareValidator = value;
3457 internal LabelLiteral NewPasswordLabel {
3459 return _newPasswordLabel;
3462 _newPasswordLabel = value;
3466 internal RequiredFieldValidator NewPasswordRequired {
3468 return _newPasswordRequired;
3472 _newPasswordRequired = value;
3476 internal Control NewPasswordTextBox {
3478 if (_newPasswordTextBox != null) {
3479 return _newPasswordTextBox;
3482 return FindRequiredControl<IEditableTextControl>(_newPasswordID, SR.ChangePassword_NoNewPasswordTextBox);
3486 _newPasswordTextBox = value;
3490 internal Literal PasswordHintLabel {
3492 return _passwordHintLabel;
3495 _passwordHintLabel = value;
3499 internal Image PasswordRecoveryIcon {
3501 return _passwordRecoveryIcon;
3504 _passwordRecoveryIcon = value;
3508 internal HyperLink PasswordRecoveryLink {
3510 return _passwordRecoveryLink;
3513 _passwordRecoveryLink = value;
3517 internal RequiredFieldValidator PasswordRequired {
3519 return _passwordRequired;
3522 _passwordRequired = value;
3526 internal RegularExpressionValidator RegExpValidator {
3528 return _regExpValidator;
3531 _regExpValidator = value;
3535 internal Literal Title {
3544 internal LabelLiteral UserNameLabel {
3546 return _userNameLabel;
3549 _userNameLabel = value;
3553 internal RequiredFieldValidator UserNameRequired {
3555 return _userNameRequired;
3559 _userNameRequired = value;
3563 internal Control UserNameTextBox {
3565 if (_userNameTextBox != null) {
3566 return _userNameTextBox;
3569 // UserNameTextBox is required if DisplayUserName is true, but the control *must not* be
3570 // present if DisplayUserName is false. (VSWhidbey 393444)
3571 if (Owner.DisplayUserName) {
3572 return FindRequiredControl<IEditableTextControl>(_userNameID, SR.ChangePassword_NoUserNameTextBox);
3575 VerifyControlNotPresent<IEditableTextControl>(_userNameID, SR.ChangePassword_UserNameTextBoxNotAllowed);
3581 _userNameTextBox = value;
3587 /// Internal because used from ChangePasswordAdapter
3589 internal enum View {