1 //------------------------------------------------------------------------------
2 // <copyright file="CreateUserWizard.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
6 
7 namespace System.Web.UI.WebControls {
8     using System;
9     using System.Collections;
10     using System.Collections.Generic;
11     using System.Collections.Specialized;
12     using System.ComponentModel;
13     using System.Drawing;
14     using System.Drawing.Design;
15     using System.Globalization;
16     using System.Linq;
17     using System.Security.Permissions;
18     using System.Web.Security;
19     using System.Web.Configuration;
20     using System.Web.UI;
21     using System.Web.Util;
22     using System.Net.Mail;
23     using System.Text;
24     using System.Web.Management;
25 
26 
27     /// <devdoc>
28     ///     Displays UI that allows creating a user.
29     /// </devdoc>
30     [
31     Bindable(false),
32     DefaultEvent("CreatedUser"),
33     Designer("System.Web.UI.Design.WebControls.CreateUserWizardDesigner, " + AssemblyRef.SystemDesign),
34     ToolboxData("<{0}:CreateUserWizard runat=\"server\"> <WizardSteps> <asp:CreateUserWizardStep runat=\"server\"/> <asp:CompleteWizardStep runat=\"server\"/> </WizardSteps> </{0}:CreateUserWizard>")
35     ]
36     public class CreateUserWizard : Wizard {
37         public static readonly string ContinueButtonCommandName = "Continue";
38 
39         private string _password;
40         private string _confirmPassword;
41         private string _answer;
42         private string _unknownErrorMessage;
43         private string _validationGroup;
44         private CreateUserWizardStep _createUserStep;
45         private CompleteWizardStep _completeStep;
46         private CreateUserStepContainer _createUserStepContainer;
47         private CompleteStepContainer _completeStepContainer;
48 
49         private const string _userNameReplacementKey = "<%\\s*UserName\\s*%>";
50         private const string _passwordReplacementKey = "<%\\s*Password\\s*%>";
51 
52         private bool _failure;
53         private bool _convertingToTemplate;
54 
55         private DefaultCreateUserNavigationTemplate _defaultCreateUserNavigationTemplate;
56 
57         private const int _viewStateArrayLength = 13;
58         private Style _createUserButtonStyle;
59         private TableItemStyle _labelStyle;
60         private Style _textBoxStyle;
61         private TableItemStyle _hyperLinkStyle;
62         private TableItemStyle _instructionTextStyle;
63         private TableItemStyle _titleTextStyle;
64         private TableItemStyle _errorMessageStyle;
65         private TableItemStyle _passwordHintStyle;
66         private Style _continueButtonStyle;
67         private TableItemStyle _completeSuccessTextStyle;
68         private Style _validatorTextStyle;
69         private MailDefinition _mailDefinition;
70 
71         private static readonly object EventCreatingUser = new object();
72         private static readonly object EventCreateUserError = new object();
73         private static readonly object EventCreatedUser = new object();
74         private static readonly object EventButtonContinueClick = new object();
75         private static readonly object EventSendingMail = new object();
76         private static readonly object EventSendMailError = new object();
77 
78         private const string _createUserNavigationTemplateName = "CreateUserNavigationTemplate";
79 
80         // Needed for user template feature
81         private const string _userNameID = "UserName";
82         private const string _passwordID = "Password";
83         private const string _confirmPasswordID = "ConfirmPassword";
84         private const string _errorMessageID = "ErrorMessage";
85         private const string _emailID = "Email";
86         private const string _questionID = "Question";
87         private const string _answerID = "Answer";
88 
89         // Needed only for "convert to template" feature, otherwise unnecessary
90         private const string _userNameRequiredID = "UserNameRequired";
91         private const string _passwordRequiredID = "PasswordRequired";
92         private const string _confirmPasswordRequiredID = "ConfirmPasswordRequired";
93         private const string _passwordRegExpID = "PasswordRegExp";
94         private const string _emailRegExpID = "EmailRegExp";
95         private const string _emailRequiredID = "EmailRequired";
96         private const string _questionRequiredID = "QuestionRequired";
97         private const string _answerRequiredID = "AnswerRequired";
98         private const string _passwordCompareID = "PasswordCompare";
99         private const string _continueButtonID = "ContinueButton";
100         private const string _helpLinkID = "HelpLink";
101         private const string _editProfileLinkID = "EditProfileLink";
102         private const string _createUserStepContainerID = "CreateUserStepContainer";
103         private const string _completeStepContainerID = "CompleteStepContainer";
104         private const string _sideBarLabelID = "SideBarLabel";
105         private const ValidatorDisplay _requiredFieldValidatorDisplay = ValidatorDisplay.Static;
106         private const ValidatorDisplay _compareFieldValidatorDisplay = ValidatorDisplay.Dynamic;
107         private const ValidatorDisplay _regexpFieldValidatorDisplay = ValidatorDisplay.Dynamic;
108 
109         private TableRow _passwordHintTableRow;
110         private TableRow _questionRow;
111         private TableRow _answerRow;
112         private TableRow _emailRow;
113         private TableRow _passwordCompareRow;
114         private TableRow _passwordRegExpRow;
115         private TableRow _emailRegExpRow;
116         private TableRow _passwordTableRow;
117         private TableRow _confirmPasswordTableRow;
118 
119         private const bool _displaySideBarDefaultValue = false;
120 
121 
122         /// <devdoc>
123         ///     Creates a new instance of a CreateUserWizard.
124         /// </devdoc>
CreateUserWizard()125         public CreateUserWizard()
126             : base(_displaySideBarDefaultValue) {
127         }
128 
129         #region Public Properties
130 
131         [
132         DefaultValue(0),
133         ]
134         public override int ActiveStepIndex {
135             get {
136                 return base.ActiveStepIndex;
137             }
138             set {
139                 base.ActiveStepIndex = value;
140             }
141         }
142 
143 
144 
145         /// <devdoc>
146         ///     Gets or sets the initial value in the answer textbox.
147         /// </devdoc>
148         [
149         Localizable(true),
150         WebCategory("Appearance"),
151         DefaultValue(""),
152         Themeable(false),
153         WebSysDescription(SR.CreateUserWizard_Answer)
154         ]
155         public virtual string Answer {
156             get {
157                 return (_answer == null) ? String.Empty : _answer;
158             }
159             set {
160                 _answer = value;
161             }
162         }
163 
164         private string AnswerInternal {
165             get {
166                 string answer = Answer;
167                 if (String.IsNullOrEmpty(Answer) && _createUserStepContainer != null) {
168                     ITextControl answerTextBox = (ITextControl)_createUserStepContainer.AnswerTextBox;
169                     if (answerTextBox != null) {
170                         answer = answerTextBox.Text;
171                     }
172                 }
173                 // Pass Null instead of Empty into Membership
174                 if (String.IsNullOrEmpty(answer)) {
175                     answer = null;
176                 }
177 
178                 return answer;
179             }
180         }
181 
182 
183         /// <devdoc>
184         /// Gets or sets the text that identifies the question textbox.
185         /// </devdoc>
186         [
187         Localizable(true),
188         WebCategory("Appearance"),
189         WebSysDefaultValue(SR.CreateUserWizard_DefaultAnswerLabelText),
190         WebSysDescription(SR.CreateUserWizard_AnswerLabelText)
191         ]
192         public virtual string AnswerLabelText {
193             get {
194                 object obj = ViewState["AnswerLabelText"];
195                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultAnswerLabelText) : (string)obj;
196             }
197             set {
198                 ViewState["AnswerLabelText"] = value;
199             }
200         }
201 
202 
203         /// <devdoc>
204         ///     Gets or sets the text to be shown in the validation summary when the answer is empty.
205         /// </devdoc>
206         [
207         Localizable(true),
208         WebCategory("Validation"),
209         WebSysDefaultValue(SR.CreateUserWizard_DefaultAnswerRequiredErrorMessage),
210         WebSysDescription(SR.LoginControls_AnswerRequiredErrorMessage)
211         ]
212         public virtual string AnswerRequiredErrorMessage {
213             get {
214                 object obj = ViewState["AnswerRequiredErrorMessage"];
215                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultAnswerRequiredErrorMessage) : (string)obj;
216             }
217             set {
218                 ViewState["AnswerRequiredErrorMessage"] = value;
219             }
220         }
221 
222         [
223         WebCategory("Behavior"),
224         DefaultValue(false),
225         Themeable(false),
226         WebSysDescription(SR.CreateUserWizard_AutoGeneratePassword)
227         ]
228         public virtual bool AutoGeneratePassword {
229             get {
230                 object obj = ViewState["AutoGeneratePassword"];
231                 return (obj == null) ? false : (bool)obj;
232             }
233             set {
234                 if (AutoGeneratePassword != value) {
235                     ViewState["AutoGeneratePassword"] = value;
236                     RequiresControlsRecreation();
237                 }
238             }
239         }
240 
241 
242         /// <devdoc>
243         ///     Gets the complete step
244         /// </devdoc>
245         [
246         Browsable(false),
247         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
248         WebCategory("Appearance"),
249         WebSysDescription(SR.CreateUserWizard_CompleteStep)
250         ]
251         public CompleteWizardStep CompleteStep {
252             get {
253                 EnsureChildControls();
254                 return _completeStep;
255             }
256         }
257 
258 
259         /// <devdoc>
260         /// The text to be shown after the password has been changed.
261         /// </devdoc>
262         [
263         Localizable(true),
264         WebCategory("Appearance"),
265         WebSysDefaultValue(SR.CreateUserWizard_DefaultCompleteSuccessText),
266         WebSysDescription(SR.CreateUserWizard_CompleteSuccessText)
267         ]
268         public virtual string CompleteSuccessText {
269             get {
270                 object obj = ViewState["CompleteSuccessText"];
271                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultCompleteSuccessText) : (string)obj;
272             }
273             set {
274                 ViewState["CompleteSuccessText"] = value;
275             }
276         }
277 
278         [
279         WebCategory("Styles"),
280         DefaultValue(null),
281         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
282         NotifyParentProperty(true),
283         PersistenceMode(PersistenceMode.InnerProperty),
284         WebSysDescription(SR.CreateUserWizard_CompleteSuccessTextStyle)
285         ]
286         public TableItemStyle CompleteSuccessTextStyle {
287             get {
288                 if (_completeSuccessTextStyle == null) {
289                     _completeSuccessTextStyle = new TableItemStyle();
290                     if (IsTrackingViewState) {
291                         ((IStateManager)_completeSuccessTextStyle).TrackViewState();
292                     }
293                 }
294                 return _completeSuccessTextStyle;
295             }
296         }
297 
298 
299         /// <devdoc>
300         ///     Gets the confirm new password entered by the user.
301         /// </devdoc>
302         [
303         Browsable(false),
304         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
305         ]
306         public virtual string ConfirmPassword {
307             get {
308                 return (_confirmPassword == null) ? String.Empty : _confirmPassword;
309             }
310         }
311 
312 
313         /// <devdoc>
314         ///     Gets or sets the message that is displayed for confirm password errors
315         /// </devdoc>
316         [
317         Localizable(true),
318         WebCategory("Validation"),
319         WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordCompareErrorMessage),
320         WebSysDescription(SR.ChangePassword_ConfirmPasswordCompareErrorMessage)
321         ]
322         public virtual string ConfirmPasswordCompareErrorMessage {
323             get {
324                 object obj = ViewState["ConfirmPasswordCompareErrorMessage"];
325                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordCompareErrorMessage) : (string)obj;
326             }
327             set {
328                 ViewState["ConfirmPasswordCompareErrorMessage"] = value;
329             }
330         }
331 
332 
333         /// <devdoc>
334         ///     Gets or sets the text that identifies the new password textbox.
335         /// </devdoc>
336         [
337         Localizable(true),
338         WebCategory("Appearance"),
339         WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordLabelText),
340         WebSysDescription(SR.CreateUserWizard_ConfirmPasswordLabelText)
341         ]
342         public virtual string ConfirmPasswordLabelText {
343             get {
344                 object obj = ViewState["ConfirmPasswordLabelText"];
345                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordLabelText) : (string)obj;
346             }
347             set {
348                 ViewState["ConfirmPasswordLabelText"] = value;
349             }
350         }
351 
352 
353         /// <devdoc>
354         ///     Gets or sets the text to be shown in the validation summary when the confirm password is empty.
355         /// </devdoc>
356         [
357         Localizable(true),
358         WebCategory("Validation"),
359         WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordRequiredErrorMessage),
360         WebSysDescription(SR.LoginControls_ConfirmPasswordRequiredErrorMessage)
361         ]
362         public virtual string ConfirmPasswordRequiredErrorMessage {
363             get {
364                 object obj = ViewState["ConfirmPasswordRequiredErrorMessage"];
365                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordRequiredErrorMessage) : (string)obj;
366             }
367             set {
368                 ViewState["ConfirmPasswordRequiredErrorMessage"] = value;
369             }
370         }
371 
372 
373         /// <devdoc>
374         ///     Gets or sets the URL of an image to be displayed for the continue button.
375         /// </devdoc>
376         [
377         WebCategory("Appearance"),
378         DefaultValue(""),
379         WebSysDescription(SR.ChangePassword_ContinueButtonImageUrl),
380         Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
381         UrlProperty()
382         ]
383         public virtual string ContinueButtonImageUrl {
384             get {
385                 object obj = ViewState["ContinueButtonImageUrl"];
386                 return (obj == null) ? String.Empty : (string)obj;
387             }
388             set {
389                 ViewState["ContinueButtonImageUrl"] = value;
390             }
391         }
392 
393 
394         /// <devdoc>
395         ///     Gets the style of the continue button.
396         /// </devdoc>
397         [
398         WebCategory("Styles"),
399         DefaultValue(null),
400         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
401         NotifyParentProperty(true),
402         PersistenceMode(PersistenceMode.InnerProperty),
403         WebSysDescription(SR.CreateUserWizard_ContinueButtonStyle)
404         ]
405         public Style ContinueButtonStyle {
406             get {
407                 if (_continueButtonStyle == null) {
408                     _continueButtonStyle = new Style();
409                     if (IsTrackingViewState) {
410                         ((IStateManager)_continueButtonStyle).TrackViewState();
411                     }
412                 }
413                 return _continueButtonStyle;
414             }
415         }
416 
417 
418         /// <devdoc>
419         ///     Gets or sets the text to be shown for the continue button.
420         /// </devdoc>
421         [
422         Localizable(true),
423         WebCategory("Appearance"),
424         WebSysDefaultValue(SR.CreateUserWizard_DefaultContinueButtonText),
425         WebSysDescription(SR.CreateUserWizard_ContinueButtonText)
426         ]
427         public virtual string ContinueButtonText {
428             get {
429                 object obj = ViewState["ContinueButtonText"];
430                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultContinueButtonText) : (string)obj;
431             }
432             set {
433                 ViewState["ContinueButtonText"] = value;
434             }
435         }
436 
437 
438         /// <devdoc>
439         ///     Gets or sets the type of the continue button.
440         /// </devdoc>
441         [
442         WebCategory("Appearance"),
443         DefaultValue(ButtonType.Button),
444         WebSysDescription(SR.CreateUserWizard_ContinueButtonType)
445         ]
446         public virtual ButtonType ContinueButtonType {
447             get {
448                 object obj = ViewState["ContinueButtonType"];
449                 return (obj == null) ? ButtonType.Button : (ButtonType)obj;
450             }
451             set {
452                 if (value < ButtonType.Button || value > ButtonType.Link) {
453                     throw new ArgumentOutOfRangeException("value");
454                 }
455                 if (value != ContinueButtonType) {
456                     ViewState["ContinueButtonType"] = value;
457                 }
458             }
459         }
460 
461 
462         /// <devdoc>
463         ///     Gets or sets the URL of an image to be displayed for the continue button.
464         /// </devdoc>
465         [
466         WebCategory("Behavior"),
467         DefaultValue(""),
468         WebSysDescription(SR.LoginControls_ContinueDestinationPageUrl),
469         Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
470         Themeable(false),
471         UrlProperty()
472         ]
473         public virtual string ContinueDestinationPageUrl {
474             get {
475                 object obj = ViewState["ContinueDestinationPageUrl"];
476                 return (obj == null) ? String.Empty : (string)obj;
477             }
478             set {
479                 ViewState["ContinueDestinationPageUrl"] = value;
480             }
481         }
482 
483         private bool ConvertingToTemplate {
484             get {
485                 return (DesignMode && _convertingToTemplate);
486             }
487         }
488 
489 
490         /// <devdoc>
491         ///     Gets the create user step
492         /// </devdoc>
493         [
494         WebCategory("Appearance"),
495         Browsable(false),
496         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
497         WebSysDescription(SR.CreateUserWizard_CreateUserStep)
498         ]
499         public CreateUserWizardStep CreateUserStep {
500             get {
501                 EnsureChildControls();
502                 return _createUserStep;
503             }
504         }
505 
506 
507         /// <devdoc>
508         ///     Gets or sets the URL of an image to be displayed for the create user button.
509         /// </devdoc>
510         [
511         WebCategory("Appearance"),
512         DefaultValue(""),
513         WebSysDescription(SR.CreateUserWizard_CreateUserButtonImageUrl),
514         Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
515         UrlProperty()
516         ]
517         public virtual string CreateUserButtonImageUrl {
518             get {
519                 object obj = ViewState["CreateUserButtonImageUrl"];
520                 return (obj == null) ? String.Empty : (string)obj;
521             }
522             set {
523                 ViewState["CreateUserButtonImageUrl"] = value;
524             }
525         }
526 
527 
528         /// <devdoc>
529         ///     Gets the style of the createUser button.
530         /// </devdoc>
531         [
532         WebCategory("Styles"),
533         DefaultValue(null),
534         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
535         NotifyParentProperty(true),
536         PersistenceMode(PersistenceMode.InnerProperty),
537         WebSysDescription(SR.CreateUserWizard_CreateUserButtonStyle)
538         ]
539         public Style CreateUserButtonStyle {
540             get {
541                 if (_createUserButtonStyle == null) {
542                     _createUserButtonStyle = new Style();
543                     if (IsTrackingViewState) {
544                         ((IStateManager)_createUserButtonStyle).TrackViewState();
545                     }
546                 }
547                 return _createUserButtonStyle;
548             }
549         }
550 
551 
552         /// <devdoc>
553         ///     Gets or sets the text to be shown for the continue button.
554         /// </devdoc>
555         [
556         Localizable(true),
557         WebCategory("Appearance"),
558         WebSysDefaultValue(SR.CreateUserWizard_DefaultCreateUserButtonText),
559         WebSysDescription(SR.CreateUserWizard_CreateUserButtonText)
560         ]
561         public virtual string CreateUserButtonText {
562             get {
563                 object obj = ViewState["CreateUserButtonText"];
564                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultCreateUserButtonText) : (string)obj;
565             }
566             set {
567                 ViewState["CreateUserButtonText"] = value;
568             }
569         }
570 
571 
572         /// <devdoc>
573         ///     Gets or sets the type of the continue button.
574         /// </devdoc>
575         [
576         WebCategory("Appearance"),
577         DefaultValue(ButtonType.Button),
578         WebSysDescription(SR.CreateUserWizard_CreateUserButtonType)
579         ]
580         public virtual ButtonType CreateUserButtonType {
581             get {
582                 object obj = ViewState["CreateUserButtonType"];
583                 return (obj == null) ? ButtonType.Button : (ButtonType)obj;
584             }
585             set {
586                 if (value < ButtonType.Button || value > ButtonType.Link) {
587                     throw new ArgumentOutOfRangeException("value");
588                 }
589                 if (value != CreateUserButtonType) {
590                     ViewState["CreateUserButtonType"] = value;
591                 }
592             }
593         }
594 
595         private bool DefaultCreateUserStep {
596             get {
597                 CreateUserWizardStep step = CreateUserStep;
598                 return (step == null) ? false : step.ContentTemplate == null;
599             }
600         }
601 
602         private bool DefaultCompleteStep {
603             get {
604                 CompleteWizardStep step = CompleteStep;
605                 return (step == null) ? false : step.ContentTemplate == null;
606             }
607         }
608 
609 
610         /// <devdoc>
611         ///     Gets or sets whether the created user will be disabled
612         /// </devdoc>
613         [
614         WebCategory("Behavior"),
615         DefaultValue(false),
616         Themeable(false),
617         WebSysDescription(SR.CreateUserWizard_DisableCreatedUser)
618         ]
619         public virtual bool DisableCreatedUser {
620             get {
621                 object obj = ViewState["DisableCreatedUser"];
622                 return (obj == null) ? false : (bool)obj;
623             }
624             set {
625                 ViewState["DisableCreatedUser"] = value;
626             }
627         }
628 
629 
630         [
631         DefaultValue(false)
632         ]
633         public override bool DisplaySideBar {
634             get {
635                 return base.DisplaySideBar;
636             }
637             set {
638                 base.DisplaySideBar = value;
639             }
640         }
641 
642 
643         /// <devdoc>
644         ///     Gets or sets the message that is displayed for duplicate emails
645         /// </devdoc>
646         [
647         Localizable(true),
648         WebCategory("Appearance"),
649         WebSysDefaultValue(SR.CreateUserWizard_DefaultDuplicateEmailErrorMessage),
650         WebSysDescription(SR.CreateUserWizard_DuplicateEmailErrorMessage)
651         ]
652         public virtual string DuplicateEmailErrorMessage {
653             get {
654                 object obj = ViewState["DuplicateEmailErrorMessage"];
655                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultDuplicateEmailErrorMessage) : (string)obj;
656             }
657             set {
658                 ViewState["DuplicateEmailErrorMessage"] = value;
659             }
660         }
661 
662 
663         /// <devdoc>
664         ///     Gets or sets the message that is displayed for email errors
665         /// </devdoc>
666         [
667         Localizable(true),
668         WebCategory("Appearance"),
669         WebSysDefaultValue(SR.CreateUserWizard_DefaultDuplicateUserNameErrorMessage),
670         WebSysDescription(SR.CreateUserWizard_DuplicateUserNameErrorMessage)
671         ]
672         public virtual string DuplicateUserNameErrorMessage {
673             get {
674                 object obj = ViewState["DuplicateUserNameErrorMessage"];
675                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultDuplicateUserNameErrorMessage) : (string)obj;
676             }
677             set {
678                 ViewState["DuplicateUserNameErrorMessage"] = value;
679             }
680         }
681 
682 
683         /// <devdoc>
684         ///     Gets or sets the URL for the image shown next to the profile page.
685         /// </devdoc>
686         [
687         WebCategory("Links"),
688         DefaultValue(""),
689         WebSysDescription(SR.LoginControls_EditProfileIconUrl),
690         Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
691         UrlProperty()
692         ]
693         public virtual string EditProfileIconUrl {
694             get {
695                 object obj = ViewState["EditProfileIconUrl"];
696                 return (obj == null) ? String.Empty : (string)obj;
697             }
698             set {
699                 ViewState["EditProfileIconUrl"] = value;
700             }
701         }
702 
703 
704         /// <devdoc>
705         ///     Gets or sets the text to be shown for the edit profile page
706         /// </devdoc>
707         [
708         Localizable(true),
709         WebCategory("Links"),
710         DefaultValue(""),
711         WebSysDescription(SR.CreateUserWizard_EditProfileText)
712         ]
713         public virtual string EditProfileText {
714             get {
715                 object obj = ViewState["EditProfileText"];
716                 return (obj == null) ? String.Empty : (string)obj;
717             }
718             set {
719                 ViewState["EditProfileText"] = value;
720             }
721         }
722 
723 
724         /// <devdoc>
725         ///     Gets or sets the URL of the edit profile page.
726         /// </devdoc>
727         [
728         WebCategory("Links"),
729         DefaultValue(""),
730         WebSysDescription(SR.CreateUserWizard_EditProfileUrl),
731         Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
732         UrlProperty()
733         ]
734         public virtual string EditProfileUrl {
735             get {
736                 object obj = ViewState["EditProfileUrl"];
737                 return (obj == null) ? String.Empty : (string)obj;
738             }
739             set {
740                 ViewState["EditProfileUrl"] = value;
741             }
742         }
743 
744 
745         /// <devdoc>
746         ///     Gets or sets the initial value in the Email textbox.
747         /// </devdoc>
748         [
749         WebCategory("Appearance"),
750         DefaultValue(""),
751         WebSysDescription(SR.CreateUserWizard_Email)
752         ]
753         public virtual string Email {
754             get {
755                 object obj = ViewState["Email"];
756                 return (obj == null) ? String.Empty : (string)obj;
757             }
758             set {
759                 ViewState["Email"] = value;
760             }
761         }
762 
763         private string EmailInternal {
764             get {
765                 string email = Email;
766                 if (String.IsNullOrEmpty(email) && _createUserStepContainer != null) {
767                     ITextControl emailTextBox = (ITextControl)_createUserStepContainer.EmailTextBox;
768                     if (emailTextBox != null) {
769                         return emailTextBox.Text;
770                     }
771                 }
772                 return email;
773             }
774         }
775 
776 
777         /// <devdoc>
778         /// Gets or sets the text that identifies the email textbox.
779         /// </devdoc>
780         [
781         Localizable(true),
782         WebCategory("Appearance"),
783         WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailLabelText),
784         WebSysDescription(SR.CreateUserWizard_EmailLabelText)
785         ]
786         public virtual string EmailLabelText {
787             get {
788                 object obj = ViewState["EmailLabelText"];
789                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailLabelText) : (string)obj;
790             }
791             set {
792                 ViewState["EmailLabelText"] = value;
793             }
794         }
795 
796 
797         /// <devdoc>
798         ///     Regular expression used to validate the email address
799         /// </devdoc>
800         [
801         WebCategory("Validation"),
802         WebSysDefaultValue(""),
803         WebSysDescription(SR.CreateUserWizard_EmailRegularExpression)
804         ]
805         public virtual string EmailRegularExpression {
806             get {
807                 object obj = ViewState["EmailRegularExpression"];
808                 return (obj == null) ? String.Empty : (string)obj;
809             }
810             set {
811                 ViewState["EmailRegularExpression"] = value;
812             }
813         }
814 
815 
816         /// <devdoc>
817         ///     Gets or sets the text to be shown in the validation summary when the email fails the reg exp.
818         /// </devdoc>
819         [
820         WebCategory("Validation"),
821         WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailRegularExpressionErrorMessage),
822         WebSysDescription(SR.CreateUserWizard_EmailRegularExpressionErrorMessage)
823         ]
824         public virtual string EmailRegularExpressionErrorMessage {
825             get {
826                 object obj = ViewState["EmailRegularExpressionErrorMessage"];
827                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailRegularExpressionErrorMessage) : (string)obj;
828             }
829             set {
830                 ViewState["EmailRegularExpressionErrorMessage"] = value;
831             }
832         }
833 
834 
835         /// <devdoc>
836         ///     Gets or sets the text to be shown in the validation summary when the email is empty.
837         /// </devdoc>
838         [
839         Localizable(true),
840         WebCategory("Validation"),
841         WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailRequiredErrorMessage),
842         WebSysDescription(SR.CreateUserWizard_EmailRequiredErrorMessage)
843         ]
844         public virtual string EmailRequiredErrorMessage {
845             get {
846                 object obj = ViewState["EmailRequiredErrorMessage"];
847                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailRequiredErrorMessage) : (string)obj;
848             }
849             set {
850                 ViewState["EmailRequiredErrorMessage"] = value;
851             }
852         }
853 
854 
855         /// <devdoc>
856         ///     Gets or sets the text that is displayed for unknown errors
857         /// </devdoc>
858         [
859         Localizable(true),
860         WebCategory("Appearance"),
861         WebSysDefaultValue(SR.CreateUserWizard_DefaultUnknownErrorMessage),
862         WebSysDescription(SR.CreateUserWizard_UnknownErrorMessage)
863         ]
864         public virtual string UnknownErrorMessage {
865             get {
866                 object obj = ViewState["UnknownErrorMessage"];
867                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUnknownErrorMessage) : (string)obj;
868             }
869             set {
870                 ViewState["UnknownErrorMessage"] = value;
871             }
872         }
873 
874         /// <devdoc>
875         ///     Gets the style of the error message.
876         /// </devdoc>
877         [
878         WebCategory("Styles"),
879         DefaultValue(null),
880         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
881         NotifyParentProperty(true),
882         PersistenceMode(PersistenceMode.InnerProperty),
883         WebSysDescription(SR.CreateUserWizard_ErrorMessageStyle)
884         ]
885         public TableItemStyle ErrorMessageStyle {
886             get {
887                 if (_errorMessageStyle == null) {
888                     _errorMessageStyle = new ErrorTableItemStyle();
889                     if (IsTrackingViewState) {
890                         ((IStateManager)_errorMessageStyle).TrackViewState();
891                     }
892                 }
893                 return _errorMessageStyle;
894             }
895         }
896 
897 
898         /// <devdoc>
899         /// Gets or sets the URL of an image to be displayed for the help link.
900         /// </devdoc>
901         [
902         WebCategory("Links"),
903         DefaultValue(""),
904         WebSysDescription(SR.LoginControls_HelpPageIconUrl),
905         Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
906         UrlProperty()
907         ]
908         public virtual string HelpPageIconUrl {
909             get {
910                 object obj = ViewState["HelpPageIconUrl"];
911                 return (obj == null) ? String.Empty : (string)obj;
912             }
913             set {
914                 ViewState["HelpPageIconUrl"] = value;
915             }
916         }
917 
918 
919         /// <devdoc>
920         ///     Gets or sets the text to be shown for the help link.
921         /// </devdoc>
922         [
923         Localizable(true),
924         WebCategory("Links"),
925         DefaultValue(""),
926         WebSysDescription(SR.ChangePassword_HelpPageText)
927         ]
928         public virtual string HelpPageText {
929             get {
930                 object obj = ViewState["HelpPageText"];
931                 return (obj == null) ? String.Empty : (string)obj;
932             }
933             set {
934                 ViewState["HelpPageText"] = value;
935             }
936         }
937 
938 
939         /// <devdoc>
940         ///     Gets or sets the URL of the help page.
941         /// </devdoc>
942         [
943         WebCategory("Links"),
944         DefaultValue(""),
945         WebSysDescription(SR.LoginControls_HelpPageUrl),
946         Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
947         UrlProperty()
948         ]
949         public virtual string HelpPageUrl {
950             get {
951                 object obj = ViewState["HelpPageUrl"];
952                 return (obj == null) ? String.Empty : (string)obj;
953             }
954             set {
955                 ViewState["HelpPageUrl"] = value;
956             }
957         }
958 
959 
960         /// <devdoc>
961         ///     Gets the style of the hyperlinks.
962         /// </devdoc>
963         [
964         WebCategory("Styles"),
965         DefaultValue(null),
966         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
967         NotifyParentProperty(true),
968         PersistenceMode(PersistenceMode.InnerProperty),
969         WebSysDescription(SR.WebControl_HyperLinkStyle)
970         ]
971         public TableItemStyle HyperLinkStyle {
972             get {
973                 if (_hyperLinkStyle == null) {
974                     _hyperLinkStyle = new TableItemStyle();
975                     if (IsTrackingViewState) {
976                         ((IStateManager)_hyperLinkStyle).TrackViewState();
977                     }
978                 }
979                 return _hyperLinkStyle;
980             }
981         }
982 
983 
984         /// <devdoc>
985         ///     Gets or sets the text that is displayed to give instructions.
986         /// </devdoc>
987         [
988         Localizable(true),
989         WebCategory("Appearance"),
990         DefaultValue(""),
991         WebSysDescription(SR.WebControl_InstructionText)
992         ]
993         public virtual string InstructionText {
994             get {
995                 object obj = ViewState["InstructionText"];
996                 return (obj == null) ? String.Empty : (string)obj;
997             }
998             set {
999                 ViewState["InstructionText"] = value;
1000             }
1001         }
1002 
1003 
1004         /// <devdoc>
1005         ///     Gets the style of the instructions.
1006         /// </devdoc>
1007         [
1008         WebCategory("Styles"),
1009         DefaultValue(null),
1010         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1011         NotifyParentProperty(true),
1012         PersistenceMode(PersistenceMode.InnerProperty),
1013         WebSysDescription(SR.WebControl_InstructionTextStyle)
1014         ]
1015         public TableItemStyle InstructionTextStyle {
1016             get {
1017                 if (_instructionTextStyle == null) {
1018                     _instructionTextStyle = new TableItemStyle();
1019                     if (IsTrackingViewState) {
1020                         ((IStateManager)_instructionTextStyle).TrackViewState();
1021                     }
1022                 }
1023                 return _instructionTextStyle;
1024             }
1025         }
1026 
1027 
1028         /// <devdoc>
1029         ///     Gets or sets the message that is displayed for answer errors
1030         /// </devdoc>
1031         [
1032         Localizable(true),
1033         WebCategory("Appearance"),
1034         WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidAnswerErrorMessage),
1035         WebSysDescription(SR.CreateUserWizard_InvalidAnswerErrorMessage)
1036         ]
1037         public virtual string InvalidAnswerErrorMessage {
1038             get {
1039                 object obj = ViewState["InvalidAnswerErrorMessage"];
1040                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidAnswerErrorMessage) : (string)obj;
1041             }
1042             set {
1043                 ViewState["InvalidAnswerErrorMessage"] = value;
1044             }
1045         }
1046 
1047 
1048         /// <devdoc>
1049         ///     Gets or sets the message that is displayed for email errors
1050         /// </devdoc>
1051         [
1052         Localizable(true),
1053         WebCategory("Appearance"),
1054         WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidEmailErrorMessage),
1055         WebSysDescription(SR.CreateUserWizard_InvalidEmailErrorMessage)
1056         ]
1057         public virtual string InvalidEmailErrorMessage {
1058             get {
1059                 object obj = ViewState["InvalidEmailErrorMessage"];
1060                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidEmailErrorMessage) : (string)obj;
1061             }
1062             set {
1063                 ViewState["InvalidEmailErrorMessage"] = value;
1064             }
1065         }
1066 
1067 
1068         /// <devdoc>
1069         ///     Gets or sets the text to be shown there is a problem with the password.
1070         /// </devdoc>
1071         [
1072         Localizable(true),
1073         WebCategory("Appearance"),
1074         WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidPasswordErrorMessage),
1075         WebSysDescription(SR.CreateUserWizard_InvalidPasswordErrorMessage)
1076         ]
1077         public virtual string InvalidPasswordErrorMessage {
1078             get {
1079                 object obj = ViewState["InvalidPasswordErrorMessage"];
1080                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidPasswordErrorMessage) : (string)obj;
1081             }
1082             set {
1083                 ViewState["InvalidPasswordErrorMessage"] = value;
1084             }
1085         }
1086 
1087 
1088         /// <devdoc>
1089         ///     Gets or sets the message that is displayed for question errors
1090         /// </devdoc>
1091         [
1092         Localizable(true),
1093         WebCategory("Appearance"),
1094         WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidQuestionErrorMessage),
1095         WebSysDescription(SR.CreateUserWizard_InvalidQuestionErrorMessage)
1096         ]
1097         public virtual string InvalidQuestionErrorMessage {
1098             get {
1099                 object obj = ViewState["InvalidQuestionErrorMessage"];
1100                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidQuestionErrorMessage) : (string)obj;
1101             }
1102             set {
1103                 ViewState["InvalidQuestionErrorMessage"] = value;
1104             }
1105         }
1106 
1107 
1108         /// <devdoc>
1109         ///     Gets the style of the textbox labels.
1110         /// </devdoc>
1111         [
1112         WebCategory("Styles"),
1113         DefaultValue(null),
1114         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1115         NotifyParentProperty(true),
1116         PersistenceMode(PersistenceMode.InnerProperty),
1117         WebSysDescription(SR.LoginControls_LabelStyle)
1118         ]
1119         public TableItemStyle LabelStyle {
1120             get {
1121                 if (_labelStyle == null) {
1122                     _labelStyle = new TableItemStyle();
1123                     if (IsTrackingViewState) {
1124                         ((IStateManager)_labelStyle).TrackViewState();
1125                     }
1126                 }
1127                 return _labelStyle;
1128             }
1129         }
1130 
1131 
1132         /// <devdoc>
1133         ///     Gets or sets whether the created user will be logged into the site
1134         /// </devdoc>
1135         [
1136         WebCategory("Behavior"),
1137         DefaultValue(true),
1138         Themeable(false),
1139         WebSysDescription(SR.CreateUserWizard_LoginCreatedUser)
1140         ]
1141         public virtual bool LoginCreatedUser {
1142             get {
1143                 object obj = ViewState["LoginCreatedUser"];
1144                 return (obj == null) ? true : (bool)obj;
1145             }
1146             set {
1147                 ViewState["LoginCreatedUser"] = value;
1148             }
1149         }
1150 
1151 
1152         /// <devdoc>
1153         /// The content and format of the e-mail message that contains the new password.
1154         /// </devdoc>
1155         [
1156         WebCategory("Behavior"),
1157         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1158         NotifyParentProperty(true),
1159         PersistenceMode(PersistenceMode.InnerProperty),
1160         Themeable(false),
1161         WebSysDescription(SR.CreateUserWizard_MailDefinition)
1162         ]
1163         public MailDefinition MailDefinition {
1164             get {
1165                 if (_mailDefinition == null) {
1166                     _mailDefinition = new MailDefinition();
1167                     if (IsTrackingViewState) {
1168                         ((IStateManager)_mailDefinition).TrackViewState();
1169                     }
1170                 }
1171                 return _mailDefinition;
1172             }
1173         }
1174 
1175 
1176         /// <devdoc>
1177         ///     Gets or sets the name of the membership provider.  If null or empty, the default provider is used.
1178         /// </devdoc>
1179         [
1180         WebCategory("Data"),
1181         DefaultValue(""),
1182         Themeable(false),
1183         WebSysDescription(SR.MembershipProvider_Name)
1184         ]
1185         public virtual string MembershipProvider {
1186             get {
1187                 object obj = ViewState["MembershipProvider"];
1188                 return (obj == null) ? String.Empty : (string)obj;
1189             }
1190             set {
1191                 if (MembershipProvider != value) {
1192                     ViewState["MembershipProvider"] = value;
1193                     RequiresControlsRecreation();
1194                 }
1195             }
1196         }
1197 
1198 
1199         /// <devdoc>
1200         ///     Gets the new password entered by the user.
1201         /// </devdoc>
1202         [
1203         Browsable(false),
1204         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
1205         ]
1206         public virtual string Password {
1207             get {
1208                 return (_password == null) ? String.Empty : _password;
1209             }
1210         }
1211 
1212         private string PasswordInternal {
1213             get {
1214                 string password = Password;
1215                 if (String.IsNullOrEmpty(password) && !AutoGeneratePassword && _createUserStepContainer != null) {
1216                     ITextControl passwordTextBox = (ITextControl)_createUserStepContainer.PasswordTextBox;
1217                     if (passwordTextBox != null) {
1218                         return passwordTextBox.Text;
1219                     }
1220                 }
1221                 return password;
1222             }
1223         }
1224 
1225 
1226         /// <devdoc>
1227         /// The style of the password hint text.
1228         /// </devdoc>
1229         [
1230         WebCategory("Styles"),
1231         DefaultValue(null),
1232         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1233         NotifyParentProperty(true),
1234         PersistenceMode(PersistenceMode.InnerProperty),
1235         WebSysDescription(SR.CreateUserWizard_PasswordHintStyle)
1236         ]
1237         public TableItemStyle PasswordHintStyle {
1238             get {
1239                 if (_passwordHintStyle == null) {
1240                     _passwordHintStyle = new TableItemStyle();
1241                     if (IsTrackingViewState) {
1242                         ((IStateManager)_passwordHintStyle).TrackViewState();
1243                     }
1244                 }
1245                 return _passwordHintStyle;
1246             }
1247         }
1248 
1249 
1250         /// <devdoc>
1251         ///     Gets or sets the text for the password hint.
1252         /// </devdoc>
1253         [
1254         Localizable(true),
1255         WebCategory("Appearance"),
1256         WebSysDefaultValue(""),
1257         WebSysDescription(SR.ChangePassword_PasswordHintText)
1258         ]
1259         public virtual string PasswordHintText {
1260             get {
1261                 object obj = ViewState["PasswordHintText"];
1262                 return (obj == null) ? String.Empty : (string)obj;
1263             }
1264             set {
1265                 ViewState["PasswordHintText"] = value;
1266             }
1267         }
1268 
1269 
1270         /// <devdoc>
1271         ///     Gets or sets the text that identifies the new password textbox.
1272         /// </devdoc>
1273         [
1274         Localizable(true),
1275         WebCategory("Appearance"),
1276         WebSysDefaultValue(SR.LoginControls_DefaultPasswordLabelText),
1277         WebSysDescription(SR.LoginControls_PasswordLabelText)
1278         ]
1279         public virtual string PasswordLabelText {
1280             get {
1281                 object obj = ViewState["PasswordLabelText"];
1282                 return (obj == null) ? SR.GetString(SR.LoginControls_DefaultPasswordLabelText) : (string)obj;
1283             }
1284             set {
1285                 ViewState["PasswordLabelText"] = value;
1286             }
1287         }
1288 
1289 
1290         /// <devdoc>
1291         ///     Regular expression used to validate the new password
1292         /// </devdoc>
1293         [
1294         WebCategory("Validation"),
1295         WebSysDefaultValue(""),
1296         WebSysDescription(SR.CreateUserWizard_PasswordRegularExpression)
1297         ]
1298         public virtual string PasswordRegularExpression {
1299             get {
1300                 object obj = ViewState["PasswordRegularExpression"];
1301                 return (obj == null) ? String.Empty : (string)obj;
1302             }
1303             set {
1304                 ViewState["PasswordRegularExpression"] = value;
1305             }
1306         }
1307 
1308 
1309 
1310         /// <devdoc>
1311         ///     Gets or sets the text to be shown in the validation summary when the password fails the reg exp.
1312         /// </devdoc>
1313         [
1314         WebCategory("Validation"),
1315         WebSysDefaultValue(SR.Password_InvalidPasswordErrorMessage),
1316         WebSysDescription(SR.CreateUserWizard_PasswordRegularExpressionErrorMessage)
1317         ]
1318         public virtual string PasswordRegularExpressionErrorMessage {
1319             get {
1320                 object obj = ViewState["PasswordRegularExpressionErrorMessage"];
1321                 return (obj == null) ? SR.GetString(SR.Password_InvalidPasswordErrorMessage) : (string)obj;
1322             }
1323             set {
1324                 ViewState["PasswordRegularExpressionErrorMessage"] = value;
1325             }
1326         }
1327 
1328 
1329         /// <devdoc>
1330         ///     Gets or sets the text to be shown in the validation summary when the new password is empty.
1331         /// </devdoc>
1332         [
1333         Localizable(true),
1334         WebCategory("Validation"),
1335         WebSysDefaultValue(SR.CreateUserWizard_DefaultPasswordRequiredErrorMessage),
1336         WebSysDescription(SR.CreateUserWizard_PasswordRequiredErrorMessage)
1337         ]
1338         public virtual string PasswordRequiredErrorMessage {
1339             get {
1340                 object obj = ViewState["PasswordRequiredErrorMessage"];
1341                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultPasswordRequiredErrorMessage) : (string)obj;
1342             }
1343             set {
1344                 ViewState["PasswordRequiredErrorMessage"] = value;
1345             }
1346         }
1347 
1348 
1349         /// <devdoc>
1350         ///     Gets or sets the initial value in the question textbox.
1351         /// </devdoc>
1352         [
1353         Localizable(true),
1354         WebCategory("Appearance"),
1355         DefaultValue(""),
1356         Themeable(false),
1357         WebSysDescription(SR.CreateUserWizard_Question)
1358         ]
1359         public virtual string Question {
1360             get {
1361                 object obj = ViewState["Question"];
1362                 return (obj == null) ? String.Empty : (string)obj;
1363             }
1364             set {
1365                 ViewState["Question"] = value;
1366             }
1367         }
1368 
1369         private string QuestionInternal {
1370             get {
1371                 string question = Question;
1372                 if (String.IsNullOrEmpty(question) && _createUserStepContainer != null) {
1373                     ITextControl questionTextBox = (ITextControl)_createUserStepContainer.QuestionTextBox;
1374                     if (questionTextBox != null) {
1375                         question = questionTextBox.Text;
1376                     }
1377                 }
1378                 // Pass Null instead of Empty into Membership
1379                 if (String.IsNullOrEmpty(question)) question = null;
1380                 return question;
1381             }
1382         }
1383 
1384 
1385         /// <devdoc>
1386         ///     Gets whether an security question and answer is required to create the user
1387         /// </devdoc>
1388         [
1389         WebCategory("Validation"),
1390         DefaultValue(true),
1391         WebSysDescription(SR.CreateUserWizard_QuestionAndAnswerRequired)
1392         ]
1393         protected internal bool QuestionAndAnswerRequired {
1394             get {
1395                 if (DesignMode) {
1396                     // Don't require question and answer if the CreateUser step is templated in the designer
1397                     if (CreateUserStep != null && CreateUserStep.ContentTemplate != null) {
1398                         return false;
1399                     }
1400                     return true;
1401                 }
1402                 return LoginUtil.GetProvider(MembershipProvider).RequiresQuestionAndAnswer;
1403             }
1404         }
1405 
1406 
1407         /// <devdoc>
1408         /// Gets or sets the text that identifies the question textbox.
1409         /// </devdoc>
1410         [
1411         Localizable(true),
1412         WebCategory("Appearance"),
1413         WebSysDefaultValue(SR.CreateUserWizard_DefaultQuestionLabelText),
1414         WebSysDescription(SR.CreateUserWizard_QuestionLabelText)
1415         ]
1416         public virtual string QuestionLabelText {
1417             get {
1418                 object obj = ViewState["QuestionLabelText"];
1419                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultQuestionLabelText) : (string)obj;
1420             }
1421             set {
1422                 ViewState["QuestionLabelText"] = value;
1423             }
1424         }
1425 
1426 
1427         /// <devdoc>
1428         ///     Gets or sets the text to be shown in the validation summary when the question is empty.
1429         /// </devdoc>
1430         [
1431         Localizable(true),
1432         WebCategory("Validation"),
1433         WebSysDefaultValue(SR.CreateUserWizard_DefaultQuestionRequiredErrorMessage),
1434         WebSysDescription(SR.CreateUserWizard_QuestionRequiredErrorMessage)
1435         ]
1436         public virtual string QuestionRequiredErrorMessage {
1437             get {
1438                 object obj = ViewState["QuestionRequiredErrorMessage"];
1439                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultQuestionRequiredErrorMessage) : (string)obj;
1440             }
1441             set {
1442                 ViewState["QuestionRequiredErrorMessage"] = value;
1443             }
1444         }
1445 
1446 
1447 
1448         /// <devdoc>
1449         ///     Gets whether an email address is required to create the user
1450         /// </devdoc>
1451         [
1452         WebCategory("Behavior"),
1453         DefaultValue(true),
1454         Themeable(false),
1455         WebSysDescription(SR.CreateUserWizard_RequireEmail)
1456         ]
1457         public virtual bool RequireEmail {
1458             get {
1459                 object obj = ViewState["RequireEmail"];
1460                 return (obj == null) ? true : (bool)obj;
1461             }
1462             set {
1463                 if (RequireEmail != value) {
1464                     ViewState["RequireEmail"] = value;
1465                 }
1466             }
1467         }
1468 
1469         internal override bool ShowCustomNavigationTemplate {
1470             get {
1471                 if (base.ShowCustomNavigationTemplate) return true;
1472                 return (ActiveStep == CreateUserStep);
1473             }
1474         }
1475 
1476         [
1477         DefaultValue(""),
1478         ]
1479         public override string SkipLinkText {
1480             get {
1481                 string s = SkipLinkTextInternal;
1482                 return s == null ? String.Empty : s;
1483             }
1484             set {
1485                 base.SkipLinkText = value;
1486             }
1487         }
1488 
1489 
1490         /// <devdoc>
1491         ///     Gets or sets the style of the textboxes.
1492         /// </devdoc>
1493         [
1494         WebCategory("Styles"),
1495         DefaultValue(null),
1496         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1497         NotifyParentProperty(true),
1498         PersistenceMode(PersistenceMode.InnerProperty),
1499         WebSysDescription(SR.LoginControls_TextBoxStyle)
1500         ]
1501         public Style TextBoxStyle {
1502             get {
1503                 if (_textBoxStyle == null) {
1504                     _textBoxStyle = new Style();
1505                     if (IsTrackingViewState) {
1506                         ((IStateManager)_textBoxStyle).TrackViewState();
1507                     }
1508                 }
1509                 return _textBoxStyle;
1510             }
1511         }
1512 
1513 
1514         /// <devdoc>
1515         ///     Gets the style of the title.
1516         /// </devdoc>
1517         [
1518         WebCategory("Styles"),
1519         DefaultValue(null),
1520         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1521         NotifyParentProperty(true),
1522         PersistenceMode(PersistenceMode.InnerProperty),
1523         WebSysDescription(SR.LoginControls_TitleTextStyle)
1524         ]
1525         public TableItemStyle TitleTextStyle {
1526             get {
1527                 if (_titleTextStyle == null) {
1528                     _titleTextStyle = new TableItemStyle();
1529                     if (IsTrackingViewState) {
1530                         ((IStateManager)_titleTextStyle).TrackViewState();
1531                     }
1532                 }
1533                 return _titleTextStyle;
1534             }
1535         }
1536 
1537 
1538         /// <devdoc>
1539         ///     Gets or sets the initial value in the user name textbox.
1540         /// </devdoc>
1541         [
1542         WebCategory("Appearance"),
1543         DefaultValue(""),
1544         WebSysDescription(SR.UserName_InitialValue)
1545         ]
1546         public virtual string UserName {
1547             get {
1548                 object obj = ViewState["UserName"];
1549                 return (obj == null) ? String.Empty : (string)obj;
1550             }
1551             set {
1552                 ViewState["UserName"] = value;
1553             }
1554         }
1555 
1556         private string UserNameInternal {
1557             get {
1558                 string userName = UserName;
1559                 if (String.IsNullOrEmpty(userName) && _createUserStepContainer != null) {
1560                     ITextControl userNameTextBox = (ITextControl)_createUserStepContainer.UserNameTextBox;
1561                     if (userNameTextBox != null) {
1562                         return userNameTextBox.Text;
1563                     }
1564                 }
1565                 return userName;
1566             }
1567         }
1568 
1569 
1570         /// <devdoc>
1571         ///     Gets or sets the text that identifies the user name textbox.
1572         /// </devdoc>
1573         [
1574         Localizable(true),
1575         WebCategory("Appearance"),
1576         WebSysDefaultValue(SR.CreateUserWizard_DefaultUserNameLabelText),
1577         WebSysDescription(SR.LoginControls_UserNameLabelText)
1578         ]
1579         public virtual string UserNameLabelText {
1580             get {
1581                 object obj = ViewState["UserNameLabelText"];
1582                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUserNameLabelText) : (string)obj;
1583             }
1584             set {
1585                 ViewState["UserNameLabelText"] = value;
1586             }
1587         }
1588 
1589 
1590         /// <devdoc>
1591         ///     Gets or sets the text to be shown in the validation summary when the user name is empty.
1592         /// </devdoc>
1593         [
1594         Localizable(true),
1595         WebCategory("Validation"),
1596         WebSysDefaultValue(SR.CreateUserWizard_DefaultUserNameRequiredErrorMessage),
1597         WebSysDescription(SR.ChangePassword_UserNameRequiredErrorMessage)
1598         ]
1599         public virtual string UserNameRequiredErrorMessage {
1600             get {
1601                 object obj = ViewState["UserNameRequiredErrorMessage"];
1602                 return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUserNameRequiredErrorMessage) : (string)obj;
1603             }
1604             set {
1605                 ViewState["UserNameRequiredErrorMessage"] = value;
1606             }
1607         }
1608 
1609         [
1610         WebCategory("Styles"),
1611         DefaultValue(null),
1612         DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
1613         NotifyParentProperty(true),
1614         PersistenceMode(PersistenceMode.InnerProperty),
1615         WebSysDescription(SR.CreateUserWizard_ValidatorTextStyle)
1616         ]
1617         public Style ValidatorTextStyle {
1618             get {
1619                 if (_validatorTextStyle == null) {
1620                     _validatorTextStyle = new ErrorStyle();
1621                     if (IsTrackingViewState) {
1622                         ((IStateManager)_validatorTextStyle).TrackViewState();
1623                     }
1624                 }
1625                 return _validatorTextStyle;
1626             }
1627         }
1628 
1629         private string ValidationGroup {
1630             get {
1631                 if (_validationGroup == null) {
1632                     EnsureID();
1633                     _validationGroup = ID;
1634                 }
1635 
1636                 return _validationGroup;
1637             }
1638         }
1639 
1640 
1641         [
1642         Editor("System.Web.UI.Design.WebControls.CreateUserWizardStepCollectionEditor," + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
1643         ]
1644         public override WizardStepCollection WizardSteps {
1645             get {
1646                 return base.WizardSteps;
1647             }
1648         }
1649 
1650         #endregion
1651 
1652         #region Public Events
1653 
1654         /// <devdoc>
1655         ///     Raised on the click of the continue button.
1656         /// </devdoc>
1657         [
1658         WebCategory("Action"),
1659         WebSysDescription(SR.CreateUserWizard_ContinueButtonClick)
1660         ]
1661         public event EventHandler ContinueButtonClick {
1662             add {
1663                 Events.AddHandler(EventButtonContinueClick, value);
1664             }
1665             remove {
1666                 Events.RemoveHandler(EventButtonContinueClick, value);
1667             }
1668         }
1669 
1670 
1671         /// <devdoc>
1672         ///     Raised before a user is created.
1673         /// </devdoc>
1674         [
1675         WebCategory("Action"),
1676         WebSysDescription(SR.CreateUserWizard_CreatingUser)
1677         ]
1678         public event LoginCancelEventHandler CreatingUser {
1679             add {
1680                 Events.AddHandler(EventCreatingUser, value);
1681             }
1682             remove {
1683                 Events.RemoveHandler(EventCreatingUser, value);
1684             }
1685         }
1686 
1687 
1688         /// <devdoc>
1689         ///     Raised after a user is created.
1690         /// </devdoc>
1691         [
1692         WebCategory("Action"),
1693         WebSysDescription(SR.CreateUserWizard_CreatedUser)
1694         ]
1695         public event EventHandler CreatedUser {
1696             add {
1697                 Events.AddHandler(EventCreatedUser, value);
1698             }
1699             remove {
1700                 Events.RemoveHandler(EventCreatedUser, value);
1701             }
1702         }
1703 
1704 
1705         /// <devdoc>
1706         ///     Raised on a create user error
1707         /// </devdoc>
1708         [
1709         WebCategory("Action"),
1710         WebSysDescription(SR.CreateUserWizard_CreateUserError)
1711         ]
1712         public event CreateUserErrorEventHandler CreateUserError {
1713             add {
1714                 Events.AddHandler(EventCreateUserError, value);
1715             }
1716             remove {
1717                 Events.RemoveHandler(EventCreateUserError, value);
1718             }
1719         }
1720 
1721 
1722         /// <devdoc>
1723         /// Raised before the e-mail is sent.
1724         /// </devdoc>
1725         [
1726         WebCategory("Action"),
1727         WebSysDescription(SR.ChangePassword_SendingMail)
1728         ]
1729         public event MailMessageEventHandler SendingMail {
1730             add {
1731                 Events.AddHandler(EventSendingMail, value);
1732             }
1733             remove {
1734                 Events.RemoveHandler(EventSendingMail, value);
1735             }
1736         }
1737 
1738 
1739         /// <devdoc>
1740         ///     Raised when there is an error sending mail.
1741         /// </devdoc>
1742         [
1743         WebCategory("Action"),
1744         WebSysDescription(SR.CreateUserWizard_SendMailError)
1745         ]
1746         public event SendMailErrorEventHandler SendMailError {
1747             add {
1748                 Events.AddHandler(EventSendMailError, value);
1749             }
1750             remove {
1751                 Events.RemoveHandler(EventSendMailError, value);
1752             }
1753         }
1754 
1755         #endregion
1756 
AnswerTextChanged(object source, EventArgs e)1757         private void AnswerTextChanged(object source, EventArgs e) {
1758             Answer = ((ITextControl)source).Text;
1759         }
1760 
1761         /// <devdoc>
1762         ///     Sets the properties of child controls that are editable by the client.
1763         /// </devdoc>
ApplyCommonCreateUserValues()1764         private void ApplyCommonCreateUserValues() {
1765             // We need to use Internal for the DropDownList case where it won't fire a TextChanged for the first item
1766             if (!String.IsNullOrEmpty(UserNameInternal)) {
1767                 ITextControl userNameTextBox = (ITextControl)_createUserStepContainer.UserNameTextBox;
1768                 if (userNameTextBox != null) {
1769                     userNameTextBox.Text = UserNameInternal;
1770                 }
1771             }
1772 
1773             if (!String.IsNullOrEmpty(EmailInternal)) {
1774                 ITextControl emailTextBox = (ITextControl)_createUserStepContainer.EmailTextBox;
1775                 if (emailTextBox != null) {
1776                     emailTextBox.Text = EmailInternal;
1777                 }
1778             }
1779 
1780             if (!String.IsNullOrEmpty(QuestionInternal)) {
1781                 ITextControl questionTextBox = (ITextControl)_createUserStepContainer.QuestionTextBox;
1782                 if (questionTextBox != null) {
1783                     questionTextBox.Text = QuestionInternal;
1784                 }
1785             }
1786 
1787             if (!String.IsNullOrEmpty(AnswerInternal)) {
1788                 ITextControl answerTextBox = (ITextControl)_createUserStepContainer.AnswerTextBox;
1789                 if (answerTextBox != null) {
1790                     answerTextBox.Text = AnswerInternal;
1791                 }
1792             }
1793         }
1794 
ApplyDefaultCreateUserValues()1795         private void ApplyDefaultCreateUserValues() {
1796             _createUserStepContainer.UserNameLabel.Text = UserNameLabelText;
1797             WebControl userTextBox = (WebControl)_createUserStepContainer.UserNameTextBox;
1798             userTextBox.TabIndex = TabIndex;
1799             userTextBox.AccessKey = AccessKey;
1800 
1801             _createUserStepContainer.PasswordLabel.Text = PasswordLabelText;
1802             WebControl passwordTextBox = (WebControl)_createUserStepContainer.PasswordTextBox;
1803             passwordTextBox.TabIndex = TabIndex;
1804 
1805             _createUserStepContainer.ConfirmPasswordLabel.Text = ConfirmPasswordLabelText;
1806             WebControl confirmTextBox = (WebControl)_createUserStepContainer.ConfirmPasswordTextBox;
1807             confirmTextBox.TabIndex = TabIndex;
1808 
1809             if (_textBoxStyle != null) {
1810                 userTextBox.ApplyStyle(_textBoxStyle);
1811                 passwordTextBox.ApplyStyle(_textBoxStyle);
1812                 confirmTextBox.ApplyStyle(_textBoxStyle);
1813             }
1814 
1815             LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.Title, CreateUserStep.Title, TitleTextStyle, true);
1816             LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.InstructionLabel, InstructionText, InstructionTextStyle, true);
1817             LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.UserNameLabel, UserNameLabelText, LabelStyle, false);
1818             LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.PasswordLabel, PasswordLabelText, LabelStyle, false);
1819             LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.ConfirmPasswordLabel, ConfirmPasswordLabelText, LabelStyle, false);
1820 
1821             // VSWhidbey 447805 Do not render PasswordHintText if AutoGeneratePassword is false.
1822             if (!String.IsNullOrEmpty(PasswordHintText) && !AutoGeneratePassword) {
1823                 LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.PasswordHintLabel, PasswordHintText, PasswordHintStyle, false);
1824             } else {
1825                 _passwordHintTableRow.Visible = false;
1826             }
1827 
1828             bool enableValidation = true;
1829 
1830             WebControl emailTextBox = null;
1831             if (RequireEmail) {
1832                 LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.EmailLabel, EmailLabelText, LabelStyle, false);
1833                 emailTextBox = (WebControl)_createUserStepContainer.EmailTextBox;
1834                 ((ITextControl)emailTextBox).Text = Email;
1835                 RequiredFieldValidator emailRequired = _createUserStepContainer.EmailRequired;
1836                 emailRequired.ToolTip = EmailRequiredErrorMessage;
1837                 emailRequired.ErrorMessage = EmailRequiredErrorMessage;
1838                 emailRequired.Enabled = enableValidation;
1839                 emailRequired.Visible = enableValidation;
1840                 if (_validatorTextStyle != null) {
1841                     emailRequired.ApplyStyle(_validatorTextStyle);
1842                 }
1843 
1844                 emailTextBox.TabIndex = TabIndex;
1845                 if (_textBoxStyle != null) {
1846                     emailTextBox.ApplyStyle(_textBoxStyle);
1847                 }
1848             } else {
1849                 _emailRow.Visible = false;
1850             }
1851 
1852             WebControl questionTextBox = null;
1853             WebControl answerTextBox = null;
1854             RequiredFieldValidator questionRequired = _createUserStepContainer.QuestionRequired;
1855             RequiredFieldValidator answerRequired = _createUserStepContainer.AnswerRequired;
1856             bool qaValidatorsEnabled = enableValidation && QuestionAndAnswerRequired;
1857             questionRequired.Enabled = qaValidatorsEnabled;
1858             questionRequired.Visible = qaValidatorsEnabled;
1859             answerRequired.Enabled = qaValidatorsEnabled;
1860             answerRequired.Visible = qaValidatorsEnabled;
1861             if (QuestionAndAnswerRequired) {
1862                 LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.QuestionLabel, QuestionLabelText, LabelStyle, false);
1863                 questionTextBox = (WebControl)_createUserStepContainer.QuestionTextBox;
1864                 ((ITextControl)questionTextBox).Text = Question;
1865                 questionTextBox.TabIndex = TabIndex;
1866                 LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.AnswerLabel, AnswerLabelText, LabelStyle, false);
1867 
1868                 answerTextBox = (WebControl)_createUserStepContainer.AnswerTextBox;
1869                 ((ITextControl)answerTextBox).Text = Answer;
1870                 answerTextBox.TabIndex = TabIndex;
1871 
1872                 if (_textBoxStyle != null) {
1873                     questionTextBox.ApplyStyle(_textBoxStyle);
1874                     answerTextBox.ApplyStyle(_textBoxStyle);
1875                 }
1876 
1877                 questionRequired.ToolTip = QuestionRequiredErrorMessage;
1878                 questionRequired.ErrorMessage = QuestionRequiredErrorMessage;
1879 
1880                 answerRequired.ToolTip = AnswerRequiredErrorMessage;
1881                 answerRequired.ErrorMessage = AnswerRequiredErrorMessage;
1882 
1883                 if (_validatorTextStyle != null) {
1884                     questionRequired.ApplyStyle(_validatorTextStyle);
1885                     answerRequired.ApplyStyle(_validatorTextStyle);
1886                 }
1887             } else {
1888                 _questionRow.Visible = false;
1889                 _answerRow.Visible = false;
1890             }
1891 
1892             if (_defaultCreateUserNavigationTemplate != null) {
1893                 ((BaseNavigationTemplateContainer)(CreateUserStep.CustomNavigationTemplateContainer)).NextButton = _defaultCreateUserNavigationTemplate.CreateUserButton;
1894                 ((BaseNavigationTemplateContainer)(CreateUserStep.CustomNavigationTemplateContainer)).CancelButton = _defaultCreateUserNavigationTemplate.CancelButton;
1895             }
1896 
1897             RequiredFieldValidator passwordRequired = _createUserStepContainer.PasswordRequired;
1898             RequiredFieldValidator confirmPasswordRequired = _createUserStepContainer.ConfirmPasswordRequired;
1899             CompareValidator passwordCompareValidator = _createUserStepContainer.PasswordCompareValidator;
1900             RegularExpressionValidator regExpValidator = _createUserStepContainer.PasswordRegExpValidator;
1901             bool passwordValidatorsEnabled = enableValidation && !AutoGeneratePassword;
1902             passwordRequired.Enabled = passwordValidatorsEnabled;
1903             passwordRequired.Visible = passwordValidatorsEnabled;
1904             confirmPasswordRequired.Enabled = passwordValidatorsEnabled;
1905             confirmPasswordRequired.Visible = passwordValidatorsEnabled;
1906             passwordCompareValidator.Enabled = passwordValidatorsEnabled;
1907             passwordCompareValidator.Visible = passwordValidatorsEnabled;
1908 
1909             bool passRegExpEnabled = passwordValidatorsEnabled && PasswordRegularExpression.Length > 0;
1910             regExpValidator.Enabled = passRegExpEnabled;
1911             regExpValidator.Visible = passRegExpEnabled;
1912 
1913             if (!enableValidation) {
1914                 _passwordRegExpRow.Visible = false;
1915                 _passwordCompareRow.Visible = false;
1916                 _emailRegExpRow.Visible = false;
1917             }
1918 
1919             if (AutoGeneratePassword) {
1920                 _passwordTableRow.Visible = false;
1921                 _confirmPasswordTableRow.Visible = false;
1922                 _passwordRegExpRow.Visible = false;
1923                 _passwordCompareRow.Visible = false;
1924             } else {
1925                 passwordRequired.ErrorMessage = PasswordRequiredErrorMessage;
1926                 passwordRequired.ToolTip = PasswordRequiredErrorMessage;
1927 
1928                 confirmPasswordRequired.ErrorMessage = ConfirmPasswordRequiredErrorMessage;
1929                 confirmPasswordRequired.ToolTip = ConfirmPasswordRequiredErrorMessage;
1930 
1931                 passwordCompareValidator.ErrorMessage = ConfirmPasswordCompareErrorMessage;
1932 
1933                 if (_validatorTextStyle != null) {
1934                     passwordRequired.ApplyStyle(_validatorTextStyle);
1935                     confirmPasswordRequired.ApplyStyle(_validatorTextStyle);
1936                     passwordCompareValidator.ApplyStyle(_validatorTextStyle);
1937                 }
1938 
1939                 if (passRegExpEnabled) {
1940                     regExpValidator.ValidationExpression = PasswordRegularExpression;
1941                     regExpValidator.ErrorMessage = PasswordRegularExpressionErrorMessage;
1942                     if (_validatorTextStyle != null) {
1943                         regExpValidator.ApplyStyle(_validatorTextStyle);
1944                     }
1945                 } else {
1946                     _passwordRegExpRow.Visible = false;
1947 
1948                 }
1949             }
1950 
1951             RequiredFieldValidator userNameRequired = _createUserStepContainer.UserNameRequired;
1952             userNameRequired.ErrorMessage = UserNameRequiredErrorMessage;
1953             userNameRequired.ToolTip = UserNameRequiredErrorMessage;
1954             userNameRequired.Enabled = enableValidation;
1955             userNameRequired.Visible = enableValidation;
1956             if (_validatorTextStyle != null) {
1957                 userNameRequired.ApplyStyle(_validatorTextStyle);
1958             }
1959 
1960             bool emailRegExpEnabled = enableValidation && EmailRegularExpression.Length > 0 && RequireEmail;
1961             RegularExpressionValidator emailRegExpValidator = _createUserStepContainer.EmailRegExpValidator;
1962             emailRegExpValidator.Enabled = emailRegExpEnabled;
1963             emailRegExpValidator.Visible = emailRegExpEnabled;
1964             if (EmailRegularExpression.Length > 0 && RequireEmail) {
1965                 emailRegExpValidator.ValidationExpression = EmailRegularExpression;
1966                 emailRegExpValidator.ErrorMessage = EmailRegularExpressionErrorMessage;
1967                 if (_validatorTextStyle != null) {
1968                     emailRegExpValidator.ApplyStyle(_validatorTextStyle);
1969                 }
1970             } else {
1971                 _emailRegExpRow.Visible = false;
1972             }
1973 
1974             // Link Setup
1975             string helpPageText = HelpPageText;
1976             bool helpPageTextVisible = (helpPageText.Length > 0);
1977 
1978             HyperLink helpPageLink = _createUserStepContainer.HelpPageLink;
1979             Image helpPageIcon = _createUserStepContainer.HelpPageIcon;
1980             helpPageLink.Visible = helpPageTextVisible;
1981             if (helpPageTextVisible) {
1982                 helpPageLink.Text = helpPageText;
1983                 helpPageLink.NavigateUrl = HelpPageUrl;
1984                 helpPageLink.TabIndex = TabIndex;
1985             }
1986             string helpPageIconUrl = HelpPageIconUrl;
1987             bool helpPageIconVisible = (helpPageIconUrl.Length > 0);
1988             helpPageIcon.Visible = helpPageIconVisible;
1989             if (helpPageIconVisible) {
1990                 helpPageIcon.ImageUrl = helpPageIconUrl;
1991                 helpPageIcon.AlternateText = helpPageText;
1992             }
1993             LoginUtil.SetTableCellVisible(helpPageLink, helpPageTextVisible || helpPageIconVisible);
1994             if (_hyperLinkStyle != null && (helpPageTextVisible || helpPageIconVisible)) {
1995                 // Apply style except font to table cell, then apply font and forecolor to HyperLinks
1996                 // VSWhidbey 81289
1997                 TableItemStyle hyperLinkStyleExceptFont = new TableItemStyle();
1998                 hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
1999                 hyperLinkStyleExceptFont.Font.Reset();
2000                 LoginUtil.SetTableCellStyle(helpPageLink, hyperLinkStyleExceptFont);
2001                 helpPageLink.Font.CopyFrom(_hyperLinkStyle.Font);
2002                 helpPageLink.ForeColor = _hyperLinkStyle.ForeColor;
2003             }
2004 
2005             Control errorMessageLabel = _createUserStepContainer.ErrorMessageLabel;
2006             if (errorMessageLabel != null) {
2007                 if (_failure && !String.IsNullOrEmpty(_unknownErrorMessage)) {
2008                     ((ITextControl)errorMessageLabel).Text = _unknownErrorMessage;
2009                     LoginUtil.SetTableCellStyle(errorMessageLabel, ErrorMessageStyle);
2010                     LoginUtil.SetTableCellVisible(errorMessageLabel, true);
2011                 } else {
2012                     LoginUtil.SetTableCellVisible(errorMessageLabel, false);
2013                 }
2014             }
2015         }
2016 
ApplyCompleteValues()2017         private void ApplyCompleteValues() {
2018             LoginUtil.ApplyStyleToLiteral(_completeStepContainer.SuccessTextLabel, CompleteSuccessText, _completeSuccessTextStyle, true);
2019 
2020             switch (ContinueButtonType) {
2021                 case ButtonType.Link:
2022                     _completeStepContainer.ContinuePushButton.Visible = false;
2023                     _completeStepContainer.ContinueImageButton.Visible = false;
2024                     _completeStepContainer.ContinueLinkButton.Text = ContinueButtonText;
2025                     _completeStepContainer.ContinueLinkButton.ValidationGroup = ValidationGroup;
2026                     _completeStepContainer.ContinueLinkButton.TabIndex = TabIndex;
2027                     _completeStepContainer.ContinueLinkButton.AccessKey = AccessKey;
2028                     break;
2029                 case ButtonType.Button:
2030                     _completeStepContainer.ContinueLinkButton.Visible = false;
2031                     _completeStepContainer.ContinueImageButton.Visible = false;
2032                     _completeStepContainer.ContinuePushButton.Text = ContinueButtonText;
2033                     _completeStepContainer.ContinuePushButton.ValidationGroup = ValidationGroup;
2034                     _completeStepContainer.ContinuePushButton.TabIndex = TabIndex;
2035                     _completeStepContainer.ContinuePushButton.AccessKey = AccessKey;
2036                     break;
2037                 case ButtonType.Image:
2038                     _completeStepContainer.ContinueLinkButton.Visible = false;
2039                     _completeStepContainer.ContinuePushButton.Visible = false;
2040                     _completeStepContainer.ContinueImageButton.ImageUrl = ContinueButtonImageUrl;
2041                     _completeStepContainer.ContinueImageButton.AlternateText = ContinueButtonText;
2042                     _completeStepContainer.ContinueImageButton.ValidationGroup = ValidationGroup;
2043                     _completeStepContainer.ContinueImageButton.TabIndex = TabIndex;
2044                     _completeStepContainer.ContinueImageButton.AccessKey = AccessKey;
2045                     break;
2046             }
2047 
2048             if (!NavigationButtonStyle.IsEmpty) {
2049                 _completeStepContainer.ContinuePushButton.ApplyStyle(NavigationButtonStyle);
2050                 _completeStepContainer.ContinueImageButton.ApplyStyle(NavigationButtonStyle);
2051                 _completeStepContainer.ContinueLinkButton.ApplyStyle(NavigationButtonStyle);
2052             }
2053 
2054             if (_continueButtonStyle != null) {
2055                 _completeStepContainer.ContinuePushButton.ApplyStyle(_continueButtonStyle);
2056                 _completeStepContainer.ContinueImageButton.ApplyStyle(_continueButtonStyle);
2057                 _completeStepContainer.ContinueLinkButton.ApplyStyle(_continueButtonStyle);
2058             }
2059 
2060             LoginUtil.ApplyStyleToLiteral(_completeStepContainer.Title, CompleteStep.Title, _titleTextStyle, true);
2061 
2062             string editProfileText = EditProfileText;
2063             bool editProfileVisible = (editProfileText.Length > 0);
2064             HyperLink editProfileLink = _completeStepContainer.EditProfileLink;
2065             editProfileLink.Visible = editProfileVisible;
2066             if (editProfileVisible) {
2067                 editProfileLink.Text = editProfileText;
2068                 editProfileLink.NavigateUrl = EditProfileUrl;
2069                 editProfileLink.TabIndex = TabIndex;
2070                 if (_hyperLinkStyle != null) {
2071                     // Apply style except font to table cell, then apply font and forecolor to HyperLinks
2072                     // VSWhidbey 81289
2073                     Style hyperLinkStyleExceptFont = new TableItemStyle();
2074                     hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
2075                     hyperLinkStyleExceptFont.Font.Reset();
2076                     LoginUtil.SetTableCellStyle(editProfileLink, hyperLinkStyleExceptFont);
2077                     editProfileLink.Font.CopyFrom(_hyperLinkStyle.Font);
2078                     editProfileLink.ForeColor = _hyperLinkStyle.ForeColor;
2079                 }
2080             }
2081             string editProfileIconUrl = EditProfileIconUrl;
2082             bool editProfileIconVisible = (editProfileIconUrl.Length > 0);
2083             Image editProfileIcon = _completeStepContainer.EditProfileIcon;
2084             editProfileIcon.Visible = editProfileIconVisible;
2085             if (editProfileIconVisible) {
2086                 editProfileIcon.ImageUrl = editProfileIconUrl;
2087                 editProfileIcon.AlternateText = EditProfileText;
2088             }
2089             LoginUtil.SetTableCellVisible(editProfileLink, editProfileVisible || editProfileIconVisible);
2090 
2091             // Copy the styles from the StepStyle property if defined.
2092             Table table = ((CompleteStepContainer)(CompleteStep.ContentTemplateContainer)).LayoutTable;
2093             table.Height = Height;
2094             table.Width = Width;
2095         }
2096 
2097         /// <devdoc>
2098         ///     Attempts to create a user, returns false if unsuccessful
2099         /// </devdoc>
AttemptCreateUser()2100         private bool AttemptCreateUser() {
2101             if (Page != null && !Page.IsValid) {
2102                 return false;
2103             }
2104 
2105             LoginCancelEventArgs args = new LoginCancelEventArgs();
2106             OnCreatingUser(args);
2107             if (args.Cancel) return false;
2108 
2109             MembershipProvider provider = LoginUtil.GetProvider(MembershipProvider);
2110             MembershipCreateStatus status;
2111 
2112             if (AutoGeneratePassword) {
2113                 int length = Math.Max(10, Membership.MinRequiredPasswordLength);
2114                 _password = Membership.GeneratePassword(length, Membership.MinRequiredNonAlphanumericCharacters);
2115             }
2116 
2117             // CreateUser() should not throw an exception.  Status is returned through the out parameter.
2118             provider.CreateUser(UserNameInternal, PasswordInternal, EmailInternal, QuestionInternal, AnswerInternal, !DisableCreatedUser /*isApproved*/, null, out status);
2119             if (status == MembershipCreateStatus.Success) {
2120                 OnCreatedUser(EventArgs.Empty);
2121 
2122                 // Send mail if specified
2123                 if (_mailDefinition != null && !String.IsNullOrEmpty(EmailInternal)) {
2124                     LoginUtil.SendPasswordMail(EmailInternal, UserNameInternal, PasswordInternal, MailDefinition,
2125                         /*defaultSubject*/ null, /*defaultBody*/ null, OnSendingMail, OnSendMailError,
2126                                                this);
2127                 }
2128 
2129                 // Set AllowReturn to false now that we've created the user
2130                 CreateUserStep.AllowReturnInternal = false;
2131 
2132                 // Set the logged in cookie if required
2133                 if (LoginCreatedUser) {
2134                     AttemptLogin();
2135                 }
2136 
2137                 return true;
2138             } else {
2139                 // Failed to create user handling below.
2140                 // Raise the error first so users get a chance to change the failure text.
2141                 OnCreateUserError(new CreateUserErrorEventArgs(status));
2142 
2143                 switch (status) {
2144                     case MembershipCreateStatus.DuplicateEmail:
2145                         _unknownErrorMessage = DuplicateEmailErrorMessage;
2146                         break;
2147                     case MembershipCreateStatus.DuplicateUserName:
2148                         _unknownErrorMessage = DuplicateUserNameErrorMessage;
2149                         break;
2150                     case MembershipCreateStatus.InvalidAnswer:
2151                         _unknownErrorMessage = InvalidAnswerErrorMessage;
2152                         break;
2153                     case MembershipCreateStatus.InvalidEmail:
2154                         _unknownErrorMessage = InvalidEmailErrorMessage;
2155                         break;
2156                     case MembershipCreateStatus.InvalidQuestion:
2157                         _unknownErrorMessage = InvalidQuestionErrorMessage;
2158                         break;
2159                     case MembershipCreateStatus.InvalidPassword:
2160                         string invalidPasswordErrorMessage = InvalidPasswordErrorMessage;
2161                         if (!String.IsNullOrEmpty(invalidPasswordErrorMessage)) {
2162                             invalidPasswordErrorMessage = String.Format(CultureInfo.InvariantCulture, invalidPasswordErrorMessage,
2163                                 provider.MinRequiredPasswordLength, provider.MinRequiredNonAlphanumericCharacters);
2164                         }
2165                         _unknownErrorMessage = invalidPasswordErrorMessage;
2166                         break;
2167                     default:
2168                         _unknownErrorMessage = UnknownErrorMessage;
2169                         break;
2170                 }
2171 
2172                 return false;
2173             }
2174         }
2175 
AttemptLogin()2176         private void AttemptLogin() {
2177             // Try to authenticate the user
2178             MembershipProvider provider = LoginUtil.GetProvider(MembershipProvider);
2179 
2180             // ValidateUser() should not throw an exception.
2181             if (provider.ValidateUser(UserName, Password)) {
2182                 System.Web.Security.FormsAuthentication.SetAuthCookie(UserNameInternal, false);
2183             }
2184         }
2185 
ConfirmPasswordTextChanged(object source, EventArgs e)2186         private void ConfirmPasswordTextChanged(object source, EventArgs e) {
2187             if (!AutoGeneratePassword) {
2188                 _confirmPassword = ((ITextControl)source).Text;
2189             }
2190         }
2191 
2192 
2193         /// <internalonly />
2194         /// <devdoc>
2195         /// </devdoc>
CreateChildControls()2196         protected internal override void CreateChildControls() {
2197             _createUserStep = null;
2198             _completeStep = null;
2199 
2200             base.CreateChildControls();
2201             UpdateValidators();
2202         }
2203 
2204 
RegisterEvents()2205         private void RegisterEvents() {
2206             RegisterTextChangedEvent(_createUserStepContainer.UserNameTextBox, UserNameTextChanged);
2207             RegisterTextChangedEvent(_createUserStepContainer.EmailTextBox, EmailTextChanged);
2208             RegisterTextChangedEvent(_createUserStepContainer.QuestionTextBox, QuestionTextChanged);
2209             RegisterTextChangedEvent(_createUserStepContainer.AnswerTextBox, AnswerTextChanged);
2210             RegisterTextChangedEvent(_createUserStepContainer.PasswordTextBox, PasswordTextChanged);
2211             RegisterTextChangedEvent(_createUserStepContainer.ConfirmPasswordTextBox, ConfirmPasswordTextChanged);
2212         }
2213 
RegisterTextChangedEvent(Control control, Action<object, EventArgs> textChangedHandler)2214         private static void RegisterTextChangedEvent(Control control, Action<object, EventArgs> textChangedHandler) {
2215             var textBoxControl = control as IEditableTextControl;
2216             if (textBoxControl != null) {
2217                 textBoxControl.TextChanged += new EventHandler(textChangedHandler);
2218             }
2219         }
2220 
CreateTableRendering()2221         internal override Wizard.TableWizardRendering CreateTableRendering() {
2222             return new TableWizardRendering(this);
2223         }
2224 
CreateLayoutTemplateRendering()2225         internal override Wizard.LayoutTemplateWizardRendering CreateLayoutTemplateRendering() {
2226             return new LayoutTemplateWizardRendering(this);
2227         }
2228 
CreateDefaultSideBarTemplate()2229         internal override ITemplate CreateDefaultSideBarTemplate() {
2230             return new DefaultSideBarTemplate();
2231         }
2232 
CreateDefaultDataListItemTemplate()2233         internal override ITemplate CreateDefaultDataListItemTemplate() {
2234             return new DataListItemTemplate();
2235         }
2236 
2237         #region Control creation helpers
2238 
CreateTwoColumnRow(Control leftCellControl, params Control[] rightCellControls)2239         private static TableRow CreateTwoColumnRow(Control leftCellControl, params Control[] rightCellControls) {
2240             var row = CreateTableRow();
2241 
2242             var leftCell = CreateTableCell();
2243             leftCell.HorizontalAlign = HorizontalAlign.Right;
2244             leftCell.Controls.Add(leftCellControl);
2245             row.Cells.Add(leftCell);
2246 
2247             var rightCell = CreateTableCell();
2248             foreach (var control in rightCellControls) {
2249                 rightCell.Controls.Add(control);
2250             }
2251             row.Cells.Add(rightCell);
2252 
2253             return row;
2254         }
2255 
CreateDoubleSpannedColumnRow(params Control[] cellControls)2256         private static TableRow CreateDoubleSpannedColumnRow(params Control[] cellControls) {
2257             return CreateDoubleSpannedColumnRow(null /* cellHorizontalAlignment */, cellControls);
2258         }
2259 
2260         private static TableRow CreateDoubleSpannedColumnRow(HorizontalAlign? cellHorizontalAlignment, params Control[] cellControls) {
2261             var row = CreateTableRow();
2262 
2263             var cell = CreateTableCell();
2264             cell.ColumnSpan = 2;
2265             if (cellHorizontalAlignment.HasValue) {
2266                 cell.HorizontalAlign = cellHorizontalAlignment.Value;
2267             }
2268             foreach (var control in cellControls) {
2269                 cell.Controls.Add(control);
2270             }
2271             row.Cells.Add(cell);
2272 
2273             return row;
2274         }
2275 
2276 
2277         /// <devdoc>
2278         ///     Helper function to create a literal with auto id disabled
2279         /// </devdoc>
CreateLabelLiteral(Control control)2280         private static LabelLiteral CreateLabelLiteral(Control control) {
2281             LabelLiteral lit = new LabelLiteral(control);
2282             lit.PreventAutoID();
2283             return lit;
2284         }
2285 
2286         /// <devdoc>
2287         ///     Helper function to create a literal with auto id disabled
2288         /// </devdoc>
CreateLiteral()2289         private static Literal CreateLiteral() {
2290             Literal lit = new Literal();
2291             lit.PreventAutoID();
2292             return lit;
2293         }
2294 
2295         /// <devdoc>
2296         ///     Helper function to create and set properties for a required field validator
2297         /// </devdoc>
CreateRequiredFieldValidator(string id, string validationGroup, Control targetTextBox, bool enableValidation)2298         private static RequiredFieldValidator CreateRequiredFieldValidator(string id, string validationGroup, Control targetTextBox, bool enableValidation) {
2299             RequiredFieldValidator validator = new RequiredFieldValidator() {
2300                 ID = id,
2301                 ControlToValidate = targetTextBox.ID,
2302                 ValidationGroup = validationGroup,
2303                 Display = _requiredFieldValidatorDisplay,
2304                 Text = SR.GetString(SR.LoginControls_DefaultRequiredFieldValidatorText),
2305                 Enabled = enableValidation,
2306                 Visible = enableValidation
2307             };
2308             return validator;
2309         }
2310 
2311         /// <devdoc>
2312         ///     Helper function to create a table with auto id disabled
2313         /// </devdoc>
CreateTable()2314         private static Table CreateTable() {
2315             Table table = new Table();
2316             table.Width = Unit.Percentage(100);
2317             table.Height = Unit.Percentage(100);
2318             table.PreventAutoID();
2319             return table;
2320         }
2321 
2322         /// <devdoc>
2323         ///     Helper function to create a table cell with auto id disabled
2324         /// </devdoc>
CreateTableCell()2325         private static TableCell CreateTableCell() {
2326             TableCell cell = new TableCell();
2327             cell.PreventAutoID();
2328             return cell;
2329         }
2330 
2331         /// <devdoc>
2332         ///     Helper function to create a table row with auto id disabled
2333         /// </devdoc>
CreateTableRow()2334         private static TableRow CreateTableRow() {
2335             TableRow row = new LoginUtil.DisappearingTableRow();
2336             row.PreventAutoID();
2337             return row;
2338         }
2339 
2340         #endregion
2341 
2342         // Helper method to create custom navigation templates.
CreateCustomNavigationTemplates()2343         internal override void CreateCustomNavigationTemplates() {
2344             //
2345             for (int i = 0; i < WizardSteps.Count; ++i) {
2346                 TemplatedWizardStep step = WizardSteps[i] as TemplatedWizardStep;
2347                 if (step != null) {
2348                     string id = GetCustomContainerID(i);
2349                     BaseNavigationTemplateContainer container = CreateBaseNavigationTemplateContainer(id);
2350                     if (step.CustomNavigationTemplate != null) {
2351                         step.CustomNavigationTemplate.InstantiateIn(container);
2352                         step.CustomNavigationTemplateContainer = container;
2353                         container.SetEnableTheming();
2354                     } else if (step == CreateUserStep) {
2355                         ITemplate customNavigationTemplate = new DefaultCreateUserNavigationTemplate(this);
2356                         customNavigationTemplate.InstantiateIn(container);
2357                         step.CustomNavigationTemplateContainer = container;
2358                         container.RegisterButtonCommandEvents();
2359                     }
2360                     CustomNavigationContainers[step] = container;
2361                 }
2362             }
2363         }
2364 
DataListItemDataBound(object sender, WizardSideBarListControlItemEventArgs e)2365         internal override void DataListItemDataBound(object sender, WizardSideBarListControlItemEventArgs e) {
2366             var dataListItem = e.Item;
2367 
2368             // Ignore the item that is not created from DataSource
2369             if (dataListItem.ItemType != ListItemType.Item &&
2370                 dataListItem.ItemType != ListItemType.AlternatingItem &&
2371                 dataListItem.ItemType != ListItemType.SelectedItem &&
2372                 dataListItem.ItemType != ListItemType.EditItem) {
2373                 return;
2374             }
2375 
2376             // For VSWhidbey 193022, we have to support wiring up sidebar buttons in sidebar templates
2377             // so use the base implementation for this.
2378             IButtonControl button = dataListItem.FindControl(SideBarButtonID) as IButtonControl;
2379             if (button != null) {
2380                 base.DataListItemDataBound(sender, e);
2381                 return;
2382             }
2383 
2384             Label label = dataListItem.FindControl(_sideBarLabelID) as Label;
2385             if (label == null) {
2386                 if (!DesignMode) {
2387                     throw new InvalidOperationException(
2388                         SR.GetString(SR.CreateUserWizard_SideBar_Label_Not_Found, DataListID, _sideBarLabelID));
2389                 }
2390 
2391                 return;
2392             }
2393 
2394             // Apply the button style to the side bar label.
2395             label.MergeStyle(SideBarButtonStyle);
2396 
2397             // Render wizardstep title on the button control.
2398             WizardStepBase step = dataListItem.DataItem as WizardStepBase;
2399             if (step != null) {
2400                 // Need to render the sidebar tablecell.
2401                 RegisterSideBarDataListForRender();
2402 
2403                 // Use the step title if defined, otherwise use ID
2404                 if (step.Title.Length > 0) {
2405                     label.Text = step.Title;
2406                 } else {
2407                     label.Text = step.ID;
2408                 }
2409             }
2410         }
2411 
EmailTextChanged(object source, EventArgs e)2412         private void EmailTextChanged(object source, EventArgs e) {
2413             Email = ((ITextControl)source).Text;
2414         }
2415 
2416         /// <devdoc>
2417         ///     Creates the default steps if they were not specified declaritively
2418         /// </devdoc>
EnsureCreateUserSteps()2419         private void EnsureCreateUserSteps() {
2420             bool foundCreate = false;
2421             bool foundComplete = false;
2422             foreach (WizardStepBase step in WizardSteps) {
2423                 var createUserStep = step as CreateUserWizardStep;
2424                 if (createUserStep != null) {
2425                     if (foundCreate) {
2426                         throw new HttpException(SR.GetString(SR.CreateUserWizard_DuplicateCreateUserWizardStep));
2427                     }
2428 
2429                     foundCreate = true;
2430                     _createUserStep = createUserStep;
2431                 } else {
2432                     var completeStep = step as CompleteWizardStep;
2433                     if (completeStep != null) {
2434                         if (foundComplete) {
2435                             throw new HttpException(SR.GetString(SR.CreateUserWizard_DuplicateCompleteWizardStep));
2436                         }
2437 
2438                         foundComplete = true;
2439                         _completeStep = completeStep;
2440                     }
2441                 }
2442             }
2443             if (!foundCreate) {
2444                 // This default step cannot disable ViewState, otherwise AllowReturn will not work properly.
2445                 // VSWhidbey 459041
2446                 _createUserStep = new CreateUserWizardStep();
2447                 // Internally created control needs to be themed as well. VSWhidbey 377952
2448                 _createUserStep.ApplyStyleSheetSkin(Page);
2449                 WizardSteps.AddAt(0, _createUserStep);
2450                 _createUserStep.Active = true;
2451             }
2452             if (!foundComplete) {
2453                 // This default step cannot disable ViewState, otherwise AllowReturn will not work properly.
2454                 // VSWhidbey 459041
2455                 _completeStep = new CompleteWizardStep();
2456                 // Internally created control needs to be themed as well. VSWhidbey 377952
2457                 _completeStep.ApplyStyleSheetSkin(Page);
2458                 WizardSteps.Add(_completeStep);
2459             }
2460             if (ActiveStepIndex == -1) ActiveStepIndex = 0;
2461         }
2462 
2463 
2464         /// <internalonly/>
2465         /// <devdoc>
2466         /// </devdoc>
2467         [SecurityPermission(SecurityAction.Demand, Unrestricted = true)]
GetDesignModeState()2468         protected override IDictionary GetDesignModeState() {
2469             IDictionary dictionary = base.GetDesignModeState();
2470 
2471             WizardStepBase active = ActiveStep;
2472             if (active != null && active == CreateUserStep) {
2473                 dictionary[_customNavigationControls] = CustomNavigationContainers[ActiveStep].Controls;
2474             }
2475 
2476             // Needed so the failure text label is visible in the designer
2477             Control errorMessageLabel = _createUserStepContainer.ErrorMessageLabel;
2478             if (errorMessageLabel != null) {
2479                 LoginUtil.SetTableCellVisible(errorMessageLabel, true);
2480             }
2481 
2482             return dictionary;
2483         }
2484 
2485         /// <devdoc>
2486         ///     Instantiates all the content templates for each TemplatedWizardStep
2487         /// </devdoc>
InstantiateStepContentTemplates()2488         internal override void InstantiateStepContentTemplates() {
2489             bool useInnerTable = (LayoutTemplate == null);
2490             foreach (WizardStepBase step in WizardSteps) {
2491                 if (step == CreateUserStep) {
2492                     step.Controls.Clear();
2493                     _createUserStepContainer = new CreateUserStepContainer(this, useInnerTable);
2494                     _createUserStepContainer.ID = _createUserStepContainerID;
2495                     ITemplate createUserStepTemplate = CreateUserStep.ContentTemplate;
2496                     if (createUserStepTemplate == null) {
2497                         createUserStepTemplate = new DefaultCreateUserContentTemplate(this);
2498                     } else {
2499                         _createUserStepContainer.SetEnableTheming();
2500                     }
2501                     createUserStepTemplate.InstantiateIn(_createUserStepContainer.Container);
2502 
2503                     CreateUserStep.ContentTemplateContainer = _createUserStepContainer;
2504                     step.Controls.Add(_createUserStepContainer);
2505                 } else if (step == CompleteStep) {
2506                     step.Controls.Clear();
2507                     _completeStepContainer = new CompleteStepContainer(this, useInnerTable);
2508                     _completeStepContainer.ID = _completeStepContainerID;
2509                     ITemplate completeStepTemplate = CompleteStep.ContentTemplate;
2510                     if (completeStepTemplate == null) {
2511                         completeStepTemplate = new DefaultCompleteStepContentTemplate(_completeStepContainer);
2512                     }
2513                     else {
2514                         _completeStepContainer.SetEnableTheming();
2515                     }
2516                     completeStepTemplate.InstantiateIn(_completeStepContainer.Container);
2517 
2518                     CompleteStep.ContentTemplateContainer = _completeStepContainer;
2519                     step.Controls.Add(_completeStepContainer);
2520                 } else {
2521                     var templatedStep = step as TemplatedWizardStep;
2522                     if (templatedStep != null) {
2523                         InstantiateStepContentTemplate(templatedStep);
2524                     }
2525                 }
2526             }
2527         }
2528 
2529         /// <internalonly/>
2530         /// <devdoc>
2531         ///     Loads a saved state of the <see cref='System.Web.UI.WebControls.CreateUserWizard'/>.
2532         /// </devdoc>
LoadViewState(object savedState)2533         protected override void LoadViewState(object savedState) {
2534             if (savedState == null) {
2535                 base.LoadViewState(null);
2536             } else {
2537                 object[] myState = (object[])savedState;
2538                 if (myState.Length != _viewStateArrayLength) {
2539                     throw new ArgumentException(SR.GetString(SR.ViewState_InvalidViewState));
2540                 }
2541 
2542                 base.LoadViewState(myState[0]);
2543                 if (myState[1] != null) {
2544                     ((IStateManager)CreateUserButtonStyle).LoadViewState(myState[1]);
2545                 }
2546                 if (myState[2] != null) {
2547                     ((IStateManager)LabelStyle).LoadViewState(myState[2]);
2548                 }
2549                 if (myState[3] != null) {
2550                     ((IStateManager)TextBoxStyle).LoadViewState(myState[3]);
2551                 }
2552                 if (myState[4] != null) {
2553                     ((IStateManager)HyperLinkStyle).LoadViewState(myState[4]);
2554                 }
2555                 if (myState[5] != null) {
2556                     ((IStateManager)InstructionTextStyle).LoadViewState(myState[5]);
2557                 }
2558                 if (myState[6] != null) {
2559                     ((IStateManager)TitleTextStyle).LoadViewState(myState[6]);
2560                 }
2561                 if (myState[7] != null) {
2562                     ((IStateManager)ErrorMessageStyle).LoadViewState(myState[7]);
2563                 }
2564                 if (myState[8] != null) {
2565                     ((IStateManager)PasswordHintStyle).LoadViewState(myState[8]);
2566                 }
2567                 if (myState[9] != null) {
2568                     ((IStateManager)MailDefinition).LoadViewState(myState[9]);
2569                 }
2570                 if (myState[10] != null) {
2571                     ((IStateManager)ContinueButtonStyle).LoadViewState(myState[10]);
2572                 }
2573                 if (myState[11] != null) {
2574                     ((IStateManager)CompleteSuccessTextStyle).LoadViewState(myState[11]);
2575                 }
2576                 if (myState[12] != null) {
2577                     ((IStateManager)ValidatorTextStyle).LoadViewState(myState[12]);
2578                 }
2579             }
2580 
2581             UpdateValidators();
2582         }
2583 
2584         // Call this whenever ChildControlsAreCreated to ensure we clean up the old validators
UpdateValidators()2585         private void UpdateValidators() {
2586             if (DesignMode) {
2587                 return;
2588             }
2589 
2590             // Because we create our child controls during on init, we need to remove validators
2591             // from the page potentially that were created mistakenly before viewstate was loaded
2592             if (DefaultCreateUserStep && _createUserStepContainer != null) {
2593                 // Remove the validators that aren't required when autogenerating a password
2594                 if (AutoGeneratePassword) {
2595                     BaseValidator confirmPassword = _createUserStepContainer.ConfirmPasswordRequired;
2596                     if (confirmPassword != null) {
2597                         Page.Validators.Remove(confirmPassword);
2598                         confirmPassword.Enabled = false;
2599                     }
2600                     BaseValidator passwordRequired = _createUserStepContainer.PasswordRequired;
2601                     if (passwordRequired != null) {
2602                         Page.Validators.Remove(passwordRequired);
2603                         passwordRequired.Enabled = false;
2604                     }
2605                     BaseValidator passRegExp = _createUserStepContainer.PasswordRegExpValidator;
2606                     if (passRegExp != null) {
2607                         Page.Validators.Remove(passRegExp);
2608                         passRegExp.Enabled = false;
2609                     }
2610                 } else if (PasswordRegularExpression.Length <= 0) {
2611                     BaseValidator passRegExp = _createUserStepContainer.PasswordRegExpValidator;
2612                     if (passRegExp != null) {
2613                         if (Page != null) {
2614                             Page.Validators.Remove(passRegExp);
2615                         }
2616                         passRegExp.Enabled = false;
2617                     }
2618                 }
2619 
2620                 // remove the validators from the page if we don't require email
2621                 if (!RequireEmail) {
2622                     BaseValidator emailRequired = _createUserStepContainer.EmailRequired;
2623                     if (emailRequired != null) {
2624                         if (Page != null) {
2625                             Page.Validators.Remove(emailRequired);
2626                         }
2627                         emailRequired.Enabled = false;
2628                     }
2629                     BaseValidator emailRegExp = _createUserStepContainer.EmailRegExpValidator;
2630                     if (emailRegExp != null) {
2631                         if (Page != null) {
2632                             Page.Validators.Remove(emailRegExp);
2633                         }
2634                         emailRegExp.Enabled = false;
2635                     }
2636                 } else if (EmailRegularExpression.Length <= 0) {
2637                     BaseValidator emailRegExp = _createUserStepContainer.EmailRegExpValidator;
2638                     if (emailRegExp != null) {
2639                         if (Page != null) {
2640                             Page.Validators.Remove(emailRegExp);
2641                         }
2642                         emailRegExp.Enabled = false;
2643                     }
2644                 }
2645 
2646                 // remove the validators from the page if we don't require question and answer
2647                 if (!QuestionAndAnswerRequired) {
2648                     BaseValidator questionRequired = _createUserStepContainer.QuestionRequired;
2649                     if (questionRequired != null) {
2650                         if (Page != null) {
2651                             Page.Validators.Remove(questionRequired);
2652                         }
2653                         questionRequired.Enabled = false;
2654                     }
2655 
2656                     BaseValidator answerRequired = _createUserStepContainer.AnswerRequired;
2657                     if (answerRequired != null) {
2658                         if (Page != null) {
2659                             Page.Validators.Remove(answerRequired);
2660                         }
2661                         answerRequired.Enabled = false;
2662                     }
2663 
2664                 }
2665             }
2666         }
2667 
2668 
OnBubbleEvent(object source, EventArgs e)2669         protected override bool OnBubbleEvent(object source, EventArgs e) {
2670             // Intercept continue button clicks here
2671             CommandEventArgs ce = e as CommandEventArgs;
2672             if (ce != null) {
2673                 if (ce.CommandName.Equals(ContinueButtonCommandName, StringComparison.CurrentCultureIgnoreCase)) {
2674                     OnContinueButtonClick(EventArgs.Empty);
2675                     return true;
2676                 }
2677             }
2678             return base.OnBubbleEvent(source, e);
2679         }
2680 
2681 
2682         /// <devdoc>
2683         ///     Raises the ContinueClick event.
2684         /// </devdoc>
OnContinueButtonClick(EventArgs e)2685         protected virtual void OnContinueButtonClick(EventArgs e) {
2686             EventHandler handler = (EventHandler)Events[EventButtonContinueClick];
2687             if (handler != null) {
2688                 handler(this, e);
2689             }
2690 
2691             string continuePageUrl = ContinueDestinationPageUrl;
2692             if (!String.IsNullOrEmpty(continuePageUrl)) {
2693                 // we should not terminate execution of current page, to give
2694                 // page a chance to cleanup its resources.  This may be less performant though.
2695                 Page.Response.Redirect(ResolveClientUrl(continuePageUrl), false);
2696             }
2697         }
2698 
2699 
2700         /// <devdoc>
2701         ///     Raises the CreatedUser event.
2702         /// </devdoc>
OnCreatedUser(EventArgs e)2703         protected virtual void OnCreatedUser(EventArgs e) {
2704             EventHandler handler = (EventHandler)Events[EventCreatedUser];
2705             if (handler != null) {
2706                 handler(this, e);
2707             }
2708         }
2709 
2710 
2711         /// <devdoc>
2712         ///     Raises the CreateUserError event.
2713         /// </devdoc>
OnCreateUserError(CreateUserErrorEventArgs e)2714         protected virtual void OnCreateUserError(CreateUserErrorEventArgs e) {
2715             CreateUserErrorEventHandler handler = (CreateUserErrorEventHandler)Events[EventCreateUserError];
2716             if (handler != null) {
2717                 handler(this, e);
2718             }
2719         }
2720 
2721 
2722         /// <devdoc>
2723         ///     Raises the CreatingUser event.
2724         /// </devdoc>
OnCreatingUser(LoginCancelEventArgs e)2725         protected virtual void OnCreatingUser(LoginCancelEventArgs e) {
2726             LoginCancelEventHandler handler = (LoginCancelEventHandler)Events[EventCreatingUser];
2727             if (handler != null) {
2728                 handler(this, e);
2729             }
2730         }
2731 
OnNextButtonClick(WizardNavigationEventArgs e)2732         protected override void OnNextButtonClick(WizardNavigationEventArgs e) {
2733             // If they just clicked next on CreateUser, lets try creating
2734             if (WizardSteps[e.CurrentStepIndex] == _createUserStep) {
2735                 e.Cancel = (Page != null && !Page.IsValid);
2736 
2737                 if (!e.Cancel) {
2738                     // Cancel the event if there's a failure
2739                     _failure = !AttemptCreateUser();
2740                     if (_failure) {
2741                         e.Cancel = true;
2742                         ITextControl errorMessageLabel = (ITextControl)_createUserStepContainer.ErrorMessageLabel;
2743                         if (errorMessageLabel != null && !String.IsNullOrEmpty(_unknownErrorMessage)) {
2744                             errorMessageLabel.Text = _unknownErrorMessage;
2745 
2746                             var errorMessageLabelCtrl = errorMessageLabel as Control;
2747                             if (errorMessageLabelCtrl != null) {
2748                                 errorMessageLabelCtrl.Visible = true;
2749                             }
2750                         }
2751                     }
2752                 }
2753             }
2754 
2755             base.OnNextButtonClick(e);
2756         }
2757 
2758 
OnPreRender(EventArgs e)2759         protected internal override void OnPreRender(EventArgs e) {
2760             // Done for some error checking (no duplicate createuserwizard/complete steps)
2761             EnsureCreateUserSteps();
2762             base.OnPreRender(e);
2763 
2764             // VSWhidbey 438108 Make sure the MembershipProvider exists.
2765             string providerString = MembershipProvider;
2766             if (!String.IsNullOrEmpty(providerString)) {
2767                 MembershipProvider provider = Membership.Providers[providerString];
2768                 if (provider == null) {
2769                     throw new HttpException(SR.GetString(SR.WebControl_CantFindProvider));
2770                 }
2771             }
2772         }
2773 
2774 
2775         /// <devdoc>
2776         /// Raises the SendingMail event.
2777         /// </devdoc>
OnSendingMail(MailMessageEventArgs e)2778         protected virtual void OnSendingMail(MailMessageEventArgs e) {
2779             MailMessageEventHandler handler = (MailMessageEventHandler)Events[EventSendingMail];
2780             if (handler != null) {
2781                 handler(this, e);
2782             }
2783         }
2784 
2785 
2786         /// <devdoc>
2787         /// Raises the SendMailError event.
2788         /// </devdoc>
OnSendMailError(SendMailErrorEventArgs e)2789         protected virtual void OnSendMailError(SendMailErrorEventArgs e) {
2790             SendMailErrorEventHandler handler = (SendMailErrorEventHandler)Events[EventSendMailError];
2791             if (handler != null) {
2792                 handler(this, e);
2793             }
2794         }
2795 
PasswordTextChanged(object source, EventArgs e)2796         private void PasswordTextChanged(object source, EventArgs e) {
2797             if (!AutoGeneratePassword) {
2798                 _password = ((ITextControl)source).Text;
2799             }
2800         }
2801 
QuestionTextChanged(object source, EventArgs e)2802         private void QuestionTextChanged(object source, EventArgs e) {
2803             Question = ((ITextControl)source).Text;
2804         }
2805 
2806         /// <internalonly/>
2807         /// <devdoc>
2808         ///     Saves the state of the <see cref='System.Web.UI.WebControls.CreateUserWizard'/>.
2809         /// </devdoc>
SaveViewState()2810         protected override object SaveViewState() {
2811             object[] myState = new object[_viewStateArrayLength];
2812 
2813             myState[0] = base.SaveViewState();
2814             myState[1] = (_createUserButtonStyle != null) ? ((IStateManager)_createUserButtonStyle).SaveViewState() : null;
2815             myState[2] = (_labelStyle != null) ? ((IStateManager)_labelStyle).SaveViewState() : null;
2816             myState[3] = (_textBoxStyle != null) ? ((IStateManager)_textBoxStyle).SaveViewState() : null;
2817             myState[4] = (_hyperLinkStyle != null) ? ((IStateManager)_hyperLinkStyle).SaveViewState() : null;
2818             myState[5] =
2819                 (_instructionTextStyle != null) ? ((IStateManager)_instructionTextStyle).SaveViewState() : null;
2820             myState[6] = (_titleTextStyle != null) ? ((IStateManager)_titleTextStyle).SaveViewState() : null;
2821             myState[7] =
2822                 (_errorMessageStyle != null) ? ((IStateManager)_errorMessageStyle).SaveViewState() : null;
2823             myState[8] = (_passwordHintStyle != null) ? ((IStateManager)_passwordHintStyle).SaveViewState() : null;
2824             myState[9] = (_mailDefinition != null) ? ((IStateManager)_mailDefinition).SaveViewState() : null;
2825             myState[10] = (_continueButtonStyle != null) ? ((IStateManager)_continueButtonStyle).SaveViewState() : null;
2826             myState[11] = (_completeSuccessTextStyle != null) ? ((IStateManager)_completeSuccessTextStyle).SaveViewState() : null;
2827             myState[12] = (_validatorTextStyle != null) ? ((IStateManager)_validatorTextStyle).SaveViewState() : null;
2828 
2829             for (int i = 0; i < _viewStateArrayLength; i++) {
2830                 if (myState[i] != null) {
2831                     return myState;
2832                 }
2833             }
2834 
2835             // More performant to return null than an array of null values
2836             return null;
2837         }
2838 
2839         [SecurityPermission(SecurityAction.Demand, Unrestricted = true)]
SetDesignModeState(IDictionary data)2840         protected override void SetDesignModeState(IDictionary data) {
2841             if (data != null) {
2842                 object o = data["ConvertToTemplate"];
2843                 if (o != null) {
2844                     _convertingToTemplate = (bool)o;
2845                 }
2846             }
2847         }
2848 
SetChildProperties()2849         private void SetChildProperties() {
2850             ApplyCommonCreateUserValues();
2851             if (DefaultCreateUserStep) {
2852                 ApplyDefaultCreateUserValues();
2853             }
2854 
2855             if (DefaultCompleteStep) {
2856                 ApplyCompleteValues();
2857             }
2858 
2859             // Always try to apply the failure text, even if templated
2860             Control errorMessageLabel = _createUserStepContainer.ErrorMessageLabel;
2861             if (errorMessageLabel != null) {
2862                 if (_failure && !String.IsNullOrEmpty(_unknownErrorMessage)) {
2863                     ((ITextControl)errorMessageLabel).Text = _unknownErrorMessage;
2864                     errorMessageLabel.Visible = true;
2865                 } else {
2866                     errorMessageLabel.Visible = false;
2867                 }
2868             }
2869         }
2870 
SetDefaultCreateUserNavigationTemplateProperties()2871         private void SetDefaultCreateUserNavigationTemplateProperties() {
2872             Debug.Assert(_defaultCreateUserNavigationTemplate != null);
2873 
2874             WebControl createUserButton = (WebControl)_defaultCreateUserNavigationTemplate.CreateUserButton;
2875             WebControl previousButton = (WebControl)_defaultCreateUserNavigationTemplate.PreviousButton;
2876             WebControl cancelButton = (WebControl)_defaultCreateUserNavigationTemplate.CancelButton;
2877 
2878             _defaultCreateUserNavigationTemplate.ApplyLayoutStyleToInnerCells(NavigationStyle);
2879 
2880             //int createUserStepIndex = WizardSteps.IndexOf(CreateUserStep);
2881             var createUserButtonControl = (IButtonControl)createUserButton;
2882             createUserButtonControl.CausesValidation = true;
2883             createUserButtonControl.Text = CreateUserButtonText;
2884             createUserButtonControl.ValidationGroup = ValidationGroup;
2885             var previousButtonControl = (IButtonControl)previousButton;
2886             previousButtonControl.CausesValidation = false;
2887             previousButtonControl.Text = StepPreviousButtonText;
2888             ((IButtonControl)cancelButton).Text = CancelButtonText;
2889 
2890             // Apply styles and tab index to the visible buttons
2891             if (_createUserButtonStyle != null) createUserButton.ApplyStyle(_createUserButtonStyle);
2892             createUserButton.ControlStyle.MergeWith(NavigationButtonStyle);
2893             createUserButton.TabIndex = TabIndex;
2894             createUserButton.Visible = true;
2895 
2896             var createUserImageButton = createUserButton as ImageButton;
2897             if (createUserImageButton != null) {
2898                 createUserImageButton.ImageUrl = CreateUserButtonImageUrl;
2899                 createUserImageButton.AlternateText = CreateUserButtonText;
2900             }
2901 
2902             previousButton.ApplyStyle(StepPreviousButtonStyle);
2903             previousButton.ControlStyle.MergeWith(NavigationButtonStyle);
2904             previousButton.TabIndex = TabIndex;
2905 
2906             int previousStepIndex = GetPreviousStepIndex(false);
2907             if (previousStepIndex != -1 && WizardSteps[previousStepIndex].AllowReturn) {
2908                 previousButton.Visible = true;
2909             } else {
2910                 previousButton.Parent.Visible = false;
2911             }
2912 
2913             var previousImageButton = previousButton as ImageButton;
2914             if (previousImageButton != null) {
2915                 previousImageButton.AlternateText = StepPreviousButtonText;
2916                 previousImageButton.ImageUrl = StepPreviousButtonImageUrl;
2917             }
2918 
2919             if (DisplayCancelButton) {
2920                 cancelButton.ApplyStyle(CancelButtonStyle);
2921                 cancelButton.ControlStyle.MergeWith(NavigationButtonStyle);
2922                 cancelButton.TabIndex = TabIndex;
2923                 cancelButton.Visible = true;
2924 
2925                 var cancelImageButton = cancelButton as ImageButton;
2926                 if (cancelImageButton != null) {
2927                     cancelImageButton.ImageUrl = CancelButtonImageUrl;
2928                     cancelImageButton.AlternateText = CancelButtonText;
2929                 }
2930             } else {
2931                 cancelButton.Parent.Visible = false;
2932             }
2933         }
2934 
2935         /// <devdoc>
2936         ///     Marks the starting point to begin tracking and saving changes to the
2937         ///     control as part of the control viewstate.
2938         /// </devdoc>
TrackViewState()2939         protected override void TrackViewState() {
2940             base.TrackViewState();
2941 
2942             if (_createUserButtonStyle != null) {
2943                 ((IStateManager)_createUserButtonStyle).TrackViewState();
2944             }
2945             if (_labelStyle != null) {
2946                 ((IStateManager)_labelStyle).TrackViewState();
2947             }
2948             if (_textBoxStyle != null) {
2949                 ((IStateManager)_textBoxStyle).TrackViewState();
2950             }
2951             if (_hyperLinkStyle != null) {
2952                 ((IStateManager)_hyperLinkStyle).TrackViewState();
2953             }
2954             if (_instructionTextStyle != null) {
2955                 ((IStateManager)_instructionTextStyle).TrackViewState();
2956             }
2957             if (_titleTextStyle != null) {
2958                 ((IStateManager)_titleTextStyle).TrackViewState();
2959             }
2960             if (_errorMessageStyle != null) {
2961                 ((IStateManager)_errorMessageStyle).TrackViewState();
2962             }
2963             if (_passwordHintStyle != null) {
2964                 ((IStateManager)_passwordHintStyle).TrackViewState();
2965             }
2966             if (_mailDefinition != null) {
2967                 ((IStateManager)_mailDefinition).TrackViewState();
2968             }
2969             if (_continueButtonStyle != null) {
2970                 ((IStateManager)_continueButtonStyle).TrackViewState();
2971             }
2972             if (_completeSuccessTextStyle != null) {
2973                 ((IStateManager)_completeSuccessTextStyle).TrackViewState();
2974             }
2975             if (_validatorTextStyle != null) {
2976                 ((IStateManager)_validatorTextStyle).TrackViewState();
2977             }
2978         }
2979 
UserNameTextChanged(object source, EventArgs e)2980         private void UserNameTextChanged(object source, EventArgs e) {
2981             UserName = ((ITextControl)source).Text;
2982         }
2983 
2984 
2985         private new class LayoutTemplateWizardRendering : Wizard.LayoutTemplateWizardRendering {
2986             private new CreateUserWizard Owner { get; set; }
2987 
LayoutTemplateWizardRendering(CreateUserWizard owner)2988             public LayoutTemplateWizardRendering(CreateUserWizard owner)
2989                 : base(owner) {
2990                 Owner = owner;
2991             }
2992 
CreateControlHierarchy()2993             public override void CreateControlHierarchy() {
2994                 Owner.EnsureCreateUserSteps();
2995 
2996                 base.CreateControlHierarchy();
2997 
2998                 Owner.InstantiateStepContentTemplates();
2999 
3000                 Owner.RegisterEvents();
3001 
3002                 // Set the editable child control properties here for two reasons:
3003                 // - So change events will be raised if viewstate is disabled on the child controls
3004                 //   - Viewstate is always disabled for default template, and might be for user template
3005                 // - So the controls render correctly in the designer
3006                 Owner.ApplyCommonCreateUserValues();
3007             }
3008 
3009 
ApplyControlProperties()3010             public override void ApplyControlProperties() {
3011                 Owner.SetChildProperties();
3012 
3013                 if (Owner.CreateUserStep.CustomNavigationTemplate == null) {
3014                     Owner.SetDefaultCreateUserNavigationTemplateProperties();
3015                 }
3016 
3017                 base.ApplyControlProperties();
3018             }
3019         }
3020 
3021 
3022         private new class TableWizardRendering : Wizard.TableWizardRendering {
3023             private new CreateUserWizard Owner {
3024                 get;
3025                 set;
3026             }
3027 
TableWizardRendering(CreateUserWizard wizard)3028             public TableWizardRendering(CreateUserWizard wizard)
3029                 : base(wizard) {
3030                 Owner = wizard;
3031             }
3032 
ApplyControlProperties()3033             public override void ApplyControlProperties() {
3034                 Owner.SetChildProperties();
3035 
3036                 if (Owner.CreateUserStep.CustomNavigationTemplate == null) {
3037                     Owner.SetDefaultCreateUserNavigationTemplateProperties();
3038                 }
3039 
3040                 base.ApplyControlProperties();
3041             }
3042 
CreateControlHierarchy()3043             public override void CreateControlHierarchy() {
3044                 Owner.EnsureCreateUserSteps();
3045 
3046                 base.CreateControlHierarchy();
3047 
3048                 Owner.RegisterEvents();
3049 
3050                 // Set the editable child control properties here for two reasons:
3051                 // - So change events will be raised if viewstate is disabled on the child controls
3052                 //   - Viewstate is always disabled for default template, and might be for user template
3053                 // - So the controls render correctly in the designer
3054                 Owner.ApplyCommonCreateUserValues();
3055             }
3056         }
3057 
3058         private sealed class DefaultCompleteStepContentTemplate : ITemplate {
3059             private CompleteStepContainer _completeContainer;
3060 
DefaultCompleteStepContentTemplate(CompleteStepContainer container)3061             public DefaultCompleteStepContentTemplate(CompleteStepContainer container) {
3062                 _completeContainer = container;
3063             }
3064 
ConstructControls(CompleteStepContainer container)3065             private static void ConstructControls(CompleteStepContainer container) {
3066                 container.Title = CreateLiteral();
3067 
3068                 container.SuccessTextLabel = CreateLiteral();
3069 
3070                 container.EditProfileLink = new HyperLink() {
3071                     ID = _editProfileLinkID
3072                 };
3073 
3074                 container.EditProfileIcon = new Image();
3075                 container.EditProfileIcon.PreventAutoID();
3076 
3077                 container.ContinueLinkButton = new LinkButton() {
3078                     ID = _continueButtonID + "LinkButton",
3079                     CommandName = ContinueButtonCommandName,
3080                     CausesValidation = false,
3081                 };
3082 
3083                 container.ContinuePushButton = new Button() {
3084                     ID = _continueButtonID + "Button",
3085                     CommandName = ContinueButtonCommandName,
3086                     CausesValidation = false
3087                 };
3088 
3089                 container.ContinueImageButton = new ImageButton() {
3090                     ID = _continueButtonID + "ImageButton",
3091                     CommandName = ContinueButtonCommandName,
3092                     CausesValidation = false
3093                 }; ;
3094             }
3095 
LayoutControls(CompleteStepContainer container)3096             private static void LayoutControls(CompleteStepContainer container) {
3097                 Table table = CreateTable();
3098                 table.EnableViewState = false;
3099 
3100                 AddTitleRow(table, container);
3101                 AddSuccessTextRow(table, container);
3102                 AddContinueRow(table, container);
3103                 AddEditRow(table, container);
3104 
3105                 container.LayoutTable = table;
3106                 container.AddChildControl(table);
3107             }
3108 
AddTitleRow(Table table, CompleteStepContainer container)3109             private static void AddTitleRow(Table table, CompleteStepContainer container) {
3110                 var r = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.Title);
3111                 table.Rows.Add(r);
3112             }
3113 
AddSuccessTextRow(Table table, CompleteStepContainer container)3114             private static void AddSuccessTextRow(Table table, CompleteStepContainer container) {
3115                 var r = CreateTableRow();
3116                 var c = CreateTableCell();
3117                 c.Controls.Add(container.SuccessTextLabel);
3118                 r.Cells.Add(c);
3119                 table.Rows.Add(r);
3120             }
3121 
AddContinueRow(Table table, CompleteStepContainer container)3122             private static void AddContinueRow(Table table, CompleteStepContainer container) {
3123                 var r = CreateDoubleSpannedColumnRow(HorizontalAlign.Right,
3124                     container.ContinuePushButton,
3125                     container.ContinueLinkButton,
3126                     container.ContinueImageButton);
3127                 table.Rows.Add(r);
3128             }
3129 
AddEditRow(Table table, CompleteStepContainer container)3130             private static void AddEditRow(Table table, CompleteStepContainer container) {
3131                 var r = CreateDoubleSpannedColumnRow(container.EditProfileIcon, container.EditProfileLink);
3132                 table.Rows.Add(r);
3133             }
3134 
ITemplate.InstantiateIn(Control container)3135             void ITemplate.InstantiateIn(Control container) {
3136                 ConstructControls(_completeContainer);
3137                 LayoutControls(_completeContainer);
3138             }
3139         }
3140 
3141 
3142         private sealed class DefaultCreateUserContentTemplate : ITemplate {
3143             private CreateUserWizard _wizard;
3144 
DefaultCreateUserContentTemplate(CreateUserWizard wizard)3145             internal DefaultCreateUserContentTemplate(CreateUserWizard wizard) {
3146                 _wizard = wizard;
3147             }
3148 
ConstructControls(CreateUserStepContainer container)3149             private void ConstructControls(CreateUserStepContainer container) {
3150                 string validationGroup = _wizard.ValidationGroup;
3151 
3152                 container.Title = CreateLiteral();
3153                 container.InstructionLabel = CreateLiteral();
3154                 container.PasswordHintLabel = CreateLiteral();
3155 
3156                 container.UserNameTextBox = new TextBox() {
3157                     ID = _userNameID
3158                 };
3159 
3160                 // Must explicitly set the ID of controls that raise postback events
3161                 container.PasswordTextBox = new TextBox() {
3162                     ID = _passwordID,
3163                     TextMode = TextBoxMode.Password
3164                 }; ;
3165 
3166                 container.ConfirmPasswordTextBox = new TextBox() {
3167                     ID = _confirmPasswordID,
3168                     TextMode = TextBoxMode.Password
3169                 };
3170 
3171                 bool enableValidation = true;
3172                 container.UserNameRequired = CreateRequiredFieldValidator(_userNameRequiredID, validationGroup, container.UserNameTextBox, enableValidation);
3173 
3174                 container.UserNameLabel = CreateLabelLiteral(container.UserNameTextBox);
3175                 container.PasswordLabel = CreateLabelLiteral(container.PasswordTextBox);
3176                 container.ConfirmPasswordLabel = CreateLabelLiteral(container.ConfirmPasswordTextBox);
3177 
3178                 Image helpPageIcon = new Image();
3179                 helpPageIcon.PreventAutoID();
3180                 container.HelpPageIcon = helpPageIcon;
3181 
3182                 container.HelpPageLink = new HyperLink() {
3183                     ID = _helpLinkID
3184                 };
3185 
3186                 container.ErrorMessageLabel = new Literal() {
3187                     ID = _errorMessageID
3188                 };
3189 
3190                 container.EmailTextBox = new TextBox() {
3191                     ID = _emailID
3192                 };
3193 
3194                 container.EmailRequired = CreateRequiredFieldValidator(_emailRequiredID, validationGroup, container.EmailTextBox, enableValidation);
3195                 container.EmailLabel = CreateLabelLiteral(container.EmailTextBox);
3196 
3197                 container.EmailRegExpValidator = new RegularExpressionValidator() {
3198                     ID = _emailRegExpID,
3199                     ControlToValidate = _emailID,
3200                     ErrorMessage = _wizard.EmailRegularExpressionErrorMessage,
3201                     ValidationExpression = _wizard.EmailRegularExpression,
3202                     ValidationGroup = validationGroup,
3203                     Display = _regexpFieldValidatorDisplay,
3204                     Enabled = enableValidation,
3205                     Visible = enableValidation
3206                 };
3207 
3208                 container.PasswordRequired = CreateRequiredFieldValidator(_passwordRequiredID, validationGroup, container.PasswordTextBox, enableValidation);
3209                 container.ConfirmPasswordRequired = CreateRequiredFieldValidator(_confirmPasswordRequiredID, validationGroup, container.ConfirmPasswordTextBox, enableValidation);
3210 
3211                 container.PasswordRegExpValidator = new RegularExpressionValidator() {
3212                     ID = _passwordRegExpID,
3213                     ControlToValidate = _passwordID,
3214                     ErrorMessage = _wizard.PasswordRegularExpressionErrorMessage,
3215                     ValidationExpression = _wizard.PasswordRegularExpression,
3216                     ValidationGroup = validationGroup,
3217                     Display = _regexpFieldValidatorDisplay,
3218                     Enabled = enableValidation,
3219                     Visible = enableValidation,
3220                 };
3221 
3222                 container.PasswordCompareValidator = new CompareValidator() {
3223                     ID = _passwordCompareID,
3224                     ControlToValidate = _confirmPasswordID,
3225                     ControlToCompare = _passwordID,
3226                     Operator = ValidationCompareOperator.Equal,
3227                     ErrorMessage = _wizard.ConfirmPasswordCompareErrorMessage,
3228                     ValidationGroup = validationGroup,
3229                     Display = _compareFieldValidatorDisplay,
3230                     Enabled = enableValidation,
3231                     Visible = enableValidation,
3232                 };
3233 
3234                 container.QuestionTextBox = new TextBox() {
3235                     ID = _questionID
3236                 }; ;
3237 
3238                 container.AnswerTextBox = new TextBox() {
3239                     ID = _answerID
3240                 }; ;
3241 
3242                 container.QuestionRequired = CreateRequiredFieldValidator(_questionRequiredID, validationGroup, container.QuestionTextBox, enableValidation);
3243                 container.AnswerRequired = CreateRequiredFieldValidator(_answerRequiredID, validationGroup, container.AnswerTextBox, enableValidation);
3244 
3245                 container.QuestionLabel = CreateLabelLiteral(container.QuestionTextBox);
3246                 container.AnswerLabel = CreateLabelLiteral(container.AnswerTextBox);
3247             }
3248 
LayoutControls(CreateUserStepContainer container)3249             private void LayoutControls(CreateUserStepContainer container) {
3250                 Table table = CreateTable();
3251                 table.EnableViewState = false;
3252 
3253                 AddTitleRow(table, container);
3254                 AddInstructionRow(table, container);
3255                 AddUserNameRow(table, container);
3256                 AddPasswordRow(table, container);
3257                 AddPasswordHintRow(table, container);
3258                 AddConfirmPasswordRow(table, container);
3259                 AddEmailRow(table, container);
3260                 AddQuestionRow(table, container);
3261                 AddAnswerRow(table, container);
3262                 AddPasswordCompareValidatorRow(table, container);
3263                 AddPasswordRegexValidatorRow(table, container);
3264                 AddEmailRegexValidatorRow(table, container);
3265                 AddErrorMessageRow(table, container);
3266                 AddHelpPageLinkRow(table, container);
3267 
3268                 container.AddChildControl(table);
3269             }
3270 
AddTitleRow(Table table, CreateUserStepContainer container)3271             private static void AddTitleRow(Table table, CreateUserStepContainer container) {
3272                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.Title);
3273                 table.Rows.Add(row);
3274             }
3275 
AddInstructionRow(Table table, CreateUserStepContainer container)3276             private static void AddInstructionRow(Table table, CreateUserStepContainer container) {
3277                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.InstructionLabel);
3278                 row.PreventAutoID();
3279                 table.Rows.Add(row);
3280             }
3281 
AddUserNameRow(Table table, CreateUserStepContainer container)3282             private void AddUserNameRow(Table table, CreateUserStepContainer container) {
3283                 if (_wizard.ConvertingToTemplate) {
3284                     container.UserNameLabel.RenderAsLabel = true;
3285                 }
3286                 var row = CreateTwoColumnRow(container.UserNameLabel, container.UserNameTextBox, container.UserNameRequired);
3287                 table.Rows.Add(row);
3288             }
3289 
AddPasswordRow(Table table, CreateUserStepContainer container)3290             private void AddPasswordRow(Table table, CreateUserStepContainer container) {
3291                 if (_wizard.ConvertingToTemplate) {
3292                     container.PasswordLabel.RenderAsLabel = true;
3293                 }
3294                 var rightCellColumns = new List<Control>() { container.PasswordTextBox };
3295                 if (!_wizard.AutoGeneratePassword) {
3296                     rightCellColumns.Add(container.PasswordRequired);
3297                 }
3298                 var row = CreateTwoColumnRow(container.PasswordLabel, rightCellColumns.ToArray());
3299                 _wizard._passwordTableRow = row;
3300                 table.Rows.Add(row);
3301             }
3302 
AddPasswordHintRow(Table table, CreateUserStepContainer container)3303             private void AddPasswordHintRow(Table table, CreateUserStepContainer container) {
3304                 var row = CreateTableRow();
3305 
3306                 var leftCell = CreateTableCell();
3307                 row.Cells.Add(leftCell);
3308 
3309                 var rightCell = CreateTableCell();
3310                 rightCell.Controls.Add(container.PasswordHintLabel);
3311                 row.Cells.Add(rightCell);
3312 
3313                 _wizard._passwordHintTableRow = row;
3314                 table.Rows.Add(row);
3315             }
3316 
AddConfirmPasswordRow(Table table, CreateUserStepContainer container)3317             private void AddConfirmPasswordRow(Table table, CreateUserStepContainer container) {
3318                 if (_wizard.ConvertingToTemplate) {
3319                     container.ConfirmPasswordLabel.RenderAsLabel = true;
3320                 }
3321                 var rightCellColumns = new List<Control>() { container.ConfirmPasswordTextBox };
3322                 if (!_wizard.AutoGeneratePassword) {
3323                     rightCellColumns.Add(container.ConfirmPasswordRequired);
3324                 }
3325                 var row = CreateTwoColumnRow(container.ConfirmPasswordLabel, rightCellColumns.ToArray());
3326                 _wizard._confirmPasswordTableRow = row;
3327                 table.Rows.Add(row);
3328             }
3329 
AddEmailRow(Table table, CreateUserStepContainer container)3330             private void AddEmailRow(Table table, CreateUserStepContainer container) {
3331                 if (_wizard.ConvertingToTemplate) {
3332                     container.EmailLabel.RenderAsLabel = true;
3333                 }
3334                 var row = CreateTwoColumnRow(container.EmailLabel, container.EmailTextBox, container.EmailRequired);
3335                 _wizard._emailRow = row;
3336                 table.Rows.Add(row);
3337             }
3338 
AddQuestionRow(Table table, CreateUserStepContainer container)3339             private void AddQuestionRow(Table table, CreateUserStepContainer container) {
3340                 if (_wizard.ConvertingToTemplate) {
3341                     container.QuestionLabel.RenderAsLabel = true;
3342                 }
3343                 var row = CreateTwoColumnRow(container.QuestionLabel, container.QuestionTextBox, container.QuestionRequired);
3344                 _wizard._questionRow = row;
3345                 table.Rows.Add(row);
3346             }
3347 
AddAnswerRow(Table table, CreateUserStepContainer container)3348             private void AddAnswerRow(Table table, CreateUserStepContainer container) {
3349                 if (_wizard.ConvertingToTemplate) {
3350                     container.AnswerLabel.RenderAsLabel = true;
3351                 }
3352                 var row = CreateTwoColumnRow(container.AnswerLabel, container.AnswerTextBox, container.AnswerRequired);
3353                 _wizard._answerRow = row;
3354                 table.Rows.Add(row);
3355             }
3356 
AddPasswordCompareValidatorRow(Table table, CreateUserStepContainer container)3357             private void AddPasswordCompareValidatorRow(Table table, CreateUserStepContainer container) {
3358                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.PasswordCompareValidator);
3359                 _wizard._passwordCompareRow = row;
3360                 table.Rows.Add(row);
3361             }
3362 
AddPasswordRegexValidatorRow(Table table, CreateUserStepContainer container)3363             private void AddPasswordRegexValidatorRow(Table table, CreateUserStepContainer container) {
3364                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.PasswordRegExpValidator);
3365                 _wizard._passwordRegExpRow = row;
3366                 table.Rows.Add(row);
3367             }
3368 
AddEmailRegexValidatorRow(Table table, CreateUserStepContainer container)3369             private void AddEmailRegexValidatorRow(Table table, CreateUserStepContainer container) {
3370                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.EmailRegExpValidator);
3371                 _wizard._emailRegExpRow = row;
3372                 table.Rows.Add(row);
3373             }
3374 
AddErrorMessageRow(Table table, CreateUserStepContainer container)3375             private static void AddErrorMessageRow(Table table, CreateUserStepContainer container) {
3376                 var row = CreateDoubleSpannedColumnRow(HorizontalAlign.Center, container.ErrorMessageLabel);
3377                 table.Rows.Add(row);
3378             }
3379 
AddHelpPageLinkRow(Table table, CreateUserStepContainer container)3380             private static void AddHelpPageLinkRow(Table table, CreateUserStepContainer container) {
3381                 var row = CreateDoubleSpannedColumnRow(container.HelpPageIcon, container.HelpPageLink);
3382                 table.Rows.Add(row);
3383             }
3384 
ITemplate.InstantiateIn(Control container)3385             void ITemplate.InstantiateIn(Control container) {
3386                 var createUserContainer = _wizard._createUserStepContainer;
3387                 ConstructControls(createUserContainer);
3388                 LayoutControls(createUserContainer);
3389             }
3390         }
3391 
3392         private sealed class DefaultCreateUserNavigationTemplate : ITemplate {
3393             private CreateUserWizard _wizard;
3394             private TableRow _row;
3395             private IButtonControl[][] _buttons;
3396             private TableCell[] _innerCells;
3397 
DefaultCreateUserNavigationTemplate(CreateUserWizard wizard)3398             internal DefaultCreateUserNavigationTemplate(CreateUserWizard wizard) {
3399                 _wizard = wizard;
3400             }
3401 
ApplyLayoutStyleToInnerCells(TableItemStyle tableItemStyle)3402             internal void ApplyLayoutStyleToInnerCells(TableItemStyle tableItemStyle) {
3403                 // VSWhidbey 401891, apply the table layout styles to the innercells.
3404                 for (int i = 0; i < _innerCells.Length; i++) {
3405                     if (tableItemStyle.IsSet(TableItemStyle.PROP_HORZALIGN)) {
3406                         _innerCells[i].HorizontalAlign = tableItemStyle.HorizontalAlign;
3407                     }
3408 
3409                     if (tableItemStyle.IsSet(TableItemStyle.PROP_VERTALIGN)) {
3410                         _innerCells[i].VerticalAlign = tableItemStyle.VerticalAlign;
3411                     }
3412                 }
3413             }
3414 
ITemplate.InstantiateIn(Control container)3415             void ITemplate.InstantiateIn(Control container) {
3416                 _wizard._defaultCreateUserNavigationTemplate = this;
3417                 container.EnableViewState = false;
3418 
3419                 Table table = CreateTable();
3420                 table.CellSpacing = 5;
3421                 table.CellPadding = 5;
3422                 container.Controls.Add(table);
3423 
3424                 TableRow tableRow = new TableRow();
3425                 _row = tableRow;
3426                 tableRow.PreventAutoID();
3427                 tableRow.HorizontalAlign = HorizontalAlign.Right;
3428                 table.Rows.Add(tableRow);
3429 
3430                 _buttons = new IButtonControl[3][];
3431                 _buttons[0] = new IButtonControl[3];
3432                 _buttons[1] = new IButtonControl[3];
3433                 _buttons[2] = new IButtonControl[3];
3434 
3435                 _innerCells = new TableCell[3];
3436 
3437                 _innerCells[0] = CreateButtonControl(_buttons[0], _wizard.ValidationGroup, Wizard.StepPreviousButtonID, false, Wizard.MovePreviousCommandName);
3438                 _innerCells[1] = CreateButtonControl(_buttons[1], _wizard.ValidationGroup, Wizard.StepNextButtonID, true, Wizard.MoveNextCommandName);
3439                 _innerCells[2] = CreateButtonControl(_buttons[2], _wizard.ValidationGroup, Wizard.CancelButtonID, false, Wizard.CancelCommandName);
3440             }
3441 
OnPreRender(object source, EventArgs e)3442             private void OnPreRender(object source, EventArgs e) {
3443                 ((ImageButton)source).Visible = false;
3444             }
3445 
CreateButtonControl(IButtonControl[] buttons, String validationGroup, String id, bool causesValidation, string commandName)3446             private TableCell CreateButtonControl(IButtonControl[] buttons, String validationGroup, String id,
3447                 bool causesValidation, string commandName) {
3448 
3449                 LinkButton linkButton = new LinkButton() {
3450                     CausesValidation = causesValidation,
3451                     ID = id + "LinkButton",
3452                     Visible = false,
3453                     CommandName = commandName,
3454                     ValidationGroup = validationGroup
3455                 };
3456                 buttons[0] = linkButton;
3457 
3458                 ImageButton imageButton = new ImageButton() {
3459                     CausesValidation = causesValidation,
3460                     ID = id + "ImageButton",
3461                     // We need the image button to be visible because it OnPreRender is only called on visible controls
3462                     // for postbacks to work, we don't need this behavior in the designer
3463                     Visible = !_wizard.DesignMode,
3464                     CommandName = commandName,
3465                     ValidationGroup = validationGroup
3466                 };
3467                 imageButton.PreRender += new EventHandler(OnPreRender);
3468 
3469                 buttons[1] = imageButton;
3470 
3471                 Button button = new Button() {
3472                     CausesValidation = causesValidation,
3473                     ID = id + "Button",
3474                     Visible = false,
3475                     CommandName = commandName,
3476                     ValidationGroup = validationGroup,
3477                 };
3478                 buttons[2] = button;
3479 
3480                 TableCell tableCell = new TableCell();
3481                 tableCell.HorizontalAlign = HorizontalAlign.Right;
3482                 _row.Cells.Add(tableCell);
3483 
3484                 tableCell.Controls.Add(linkButton);
3485                 tableCell.Controls.Add(imageButton);
3486                 tableCell.Controls.Add(button);
3487 
3488                 return tableCell;
3489             }
3490 
3491             internal IButtonControl PreviousButton {
3492                 get {
3493                     return GetButtonBasedOnType(0, _wizard.StepPreviousButtonType);
3494                 }
3495             }
3496 
3497             internal IButtonControl CreateUserButton {
3498                 get {
3499                     return GetButtonBasedOnType(1, _wizard.CreateUserButtonType);
3500                 }
3501             }
3502 
3503             internal IButtonControl CancelButton {
3504                 get {
3505                     return GetButtonBasedOnType(2, _wizard.CancelButtonType);
3506                 }
3507             }
3508 
GetButtonBasedOnType(int pos, ButtonType type)3509             private IButtonControl GetButtonBasedOnType(int pos, ButtonType type) {
3510                 switch (type) {
3511                     case ButtonType.Button:
3512                         return _buttons[pos][2];
3513 
3514                     case ButtonType.Image:
3515                         return _buttons[pos][1];
3516 
3517                     case ButtonType.Link:
3518                         return _buttons[pos][0];
3519                 }
3520 
3521                 return null;
3522             }
3523         }
3524 
3525         private sealed class DataListItemTemplate : ITemplate {
InstantiateIn(Control container)3526             public void InstantiateIn(Control container) {
3527                 Label item = new Label();
3528                 item.PreventAutoID();
3529                 item.ID = _sideBarLabelID;
3530                 container.Controls.Add(item);
3531             }
3532         }
3533 
3534         private sealed class DefaultSideBarTemplate : ITemplate {
InstantiateIn(Control container)3535             public void InstantiateIn(Control container) {
3536                 DataList dataList = new DataList();
3537                 dataList.ID = Wizard.DataListID;
3538                 container.Controls.Add(dataList);
3539 
3540                 dataList.SelectedItemStyle.Font.Bold = true;
3541                 dataList.ItemTemplate = new DataListItemTemplate();
3542             }
3543         }
3544 
3545         private sealed class CreateUserStepContainer : BaseContentTemplateContainer {
3546             private CreateUserWizard _createUserWizard;
3547 
3548             private Control _userNameTextBox;
3549             private Control _passwordTextBox;
3550             private Control _confirmPasswordTextBox;
3551             private Control _emailTextBox;
3552             private Control _questionTextBox;
3553             private Control _answerTextBox;
3554 
3555             private Control _unknownErrorMessageLabel;
3556 
CreateUserStepContainer(CreateUserWizard wizard, bool useInnerTable)3557             internal CreateUserStepContainer(CreateUserWizard wizard, bool useInnerTable)
3558                 : base(wizard, useInnerTable) {
3559                 _createUserWizard = wizard;
3560             }
3561 
3562             internal LabelLiteral AnswerLabel { get; set; }
3563 
3564             internal RequiredFieldValidator AnswerRequired { get; set; }
3565 
3566             /// <devdoc>
3567             ///     Required control, must have type IEditableTextControl
3568             /// </devdoc>
3569             internal Control AnswerTextBox {
3570                 get {
3571                     if (_answerTextBox != null) {
3572                         return _answerTextBox;
3573                     } else {
3574                         Control answerTextBox = FindControl(_answerID);
3575                         if (answerTextBox is IEditableTextControl) {
3576                             //
3577                             return answerTextBox;
3578                         } else {
3579                             if (!_createUserWizard.DesignMode && _createUserWizard.QuestionAndAnswerRequired) {
3580                                 throw new HttpException(SR.GetString(SR.CreateUserWizard_NoAnswerTextBox,
3581                                                                                          _createUserWizard.ID, _answerID));
3582                             }
3583                             return null;
3584                         }
3585                     }
3586                 }
3587                 set {
3588                     _answerTextBox = value;
3589                 }
3590             }
3591 
3592             internal LabelLiteral ConfirmPasswordLabel { get; set; }
3593 
3594             internal RequiredFieldValidator ConfirmPasswordRequired { get; set; }
3595 
3596             internal Control ConfirmPasswordTextBox {
3597                 get {
3598                     if (_confirmPasswordTextBox != null) {
3599                         return _confirmPasswordTextBox;
3600                     } else {
3601                         Control confirmPasswordTextBox = FindControl(_confirmPasswordID);
3602                         if (confirmPasswordTextBox is IEditableTextControl) {
3603                             //
3604                             return confirmPasswordTextBox;
3605                         } else {
3606                             return null;
3607                         }
3608                     }
3609                 }
3610                 set {
3611                     _confirmPasswordTextBox = value;
3612                 }
3613             }
3614 
3615             internal LabelLiteral EmailLabel { get; set; }
3616 
3617             internal RegularExpressionValidator EmailRegExpValidator { get; set; }
3618 
3619             internal RequiredFieldValidator EmailRequired { get; set; }
3620 
3621             /// <devdoc>
3622             ///     Required control, must have type IEditableTextControl
3623             /// </devdoc>
3624             internal Control EmailTextBox {
3625                 get {
3626                     if (_emailTextBox != null) {
3627                         return _emailTextBox;
3628                     } else {
3629                         Control emailTextBox = FindControl(_emailID);
3630                         if (emailTextBox is IEditableTextControl) {
3631                             //
3632                             return emailTextBox;
3633                         } else {
3634                             if (!_createUserWizard.DesignMode && _createUserWizard.RequireEmail) {
3635                                 throw new HttpException(SR.GetString(SR.CreateUserWizard_NoEmailTextBox,
3636                                                                                          _createUserWizard.ID, _emailID));
3637                             }
3638                             return null;
3639                         }
3640                     }
3641                 }
3642                 set {
3643                     _emailTextBox = value;
3644                 }
3645             }
3646 
3647             internal LabelLiteral PasswordLabel { get; set; }
3648 
3649             /// <devdoc>
3650             ///     Optional control, must have type ITextControl
3651             /// </devdoc>
3652             internal Control ErrorMessageLabel {
3653                 get {
3654                     if (_unknownErrorMessageLabel != null) {
3655                         return _unknownErrorMessageLabel;
3656                     } else {
3657                         Control control = FindControl(_errorMessageID);
3658                         ITextControl errorMessageLabel = control as ITextControl;
3659                         if (errorMessageLabel == null) {
3660                             return null;
3661                         }
3662                         return control;
3663                     }
3664                 }
3665                 set {
3666                     _unknownErrorMessageLabel = value;
3667                 }
3668             }
3669 
3670             internal Image HelpPageIcon { get; set; }
3671 
3672             internal HyperLink HelpPageLink { get; set; }
3673 
3674             internal Literal InstructionLabel { get; set; }
3675 
3676             internal CompareValidator PasswordCompareValidator { get; set; }
3677 
3678             internal Literal PasswordHintLabel { get; set; }
3679 
3680             internal RegularExpressionValidator PasswordRegExpValidator { get; set; }
3681 
3682             internal RequiredFieldValidator PasswordRequired { get; set; }
3683 
3684             /// <devdoc>
3685             ///     Required control, must have type IEditableTextControl
3686             /// </devdoc>
3687             internal Control PasswordTextBox {
3688                 get {
3689                     if (_passwordTextBox != null) {
3690                         return _passwordTextBox;
3691                     } else {
3692                         Control passwordTextBox = FindControl(_passwordID);
3693                         if (passwordTextBox is IEditableTextControl) {
3694                             //
3695                             return passwordTextBox;
3696                         } else {
3697                             if (!_createUserWizard.DesignMode && !_createUserWizard.AutoGeneratePassword) {
3698                                 throw new HttpException(SR.GetString(SR.CreateUserWizard_NoPasswordTextBox,
3699                                                                                          _createUserWizard.ID, _passwordID));
3700                             }
3701                             return null;
3702                         }
3703                     }
3704                 }
3705                 set {
3706                     _passwordTextBox = value;
3707                 }
3708             }
3709 
3710             internal Literal Title { get; set; }
3711 
3712             internal LabelLiteral UserNameLabel { get; set; }
3713 
3714             internal RequiredFieldValidator UserNameRequired { get; set; }
3715 
3716             internal LabelLiteral QuestionLabel { get; set; }
3717 
3718             internal RequiredFieldValidator QuestionRequired { get; set; }
3719 
3720             /// <devdoc>
3721             ///     Required control, must have type IEditableTextControl
3722             /// </devdoc>
3723             internal Control QuestionTextBox {
3724                 get {
3725                     if (_questionTextBox != null) {
3726                         return _questionTextBox;
3727                     } else {
3728                         Control questionTextBox = FindControl(_questionID);
3729                         if (questionTextBox is IEditableTextControl) {
3730                             //
3731                             return questionTextBox;
3732                         } else {
3733                             if (!_createUserWizard.DesignMode && _createUserWizard.QuestionAndAnswerRequired) {
3734                                 throw new HttpException(SR.GetString(SR.CreateUserWizard_NoQuestionTextBox,
3735                                                                                          _createUserWizard.ID, _questionID));
3736                             }
3737                             return null;
3738                         }
3739                     }
3740                 }
3741                 set {
3742                     _questionTextBox = value;
3743                 }
3744             }
3745 
3746             /// <devdoc>
3747             ///     Required control, must have type IEditableTextControl
3748             /// </devdoc>
3749             internal Control UserNameTextBox {
3750                 get {
3751                     if (_userNameTextBox != null) {
3752                         return _userNameTextBox;
3753                     } else {
3754                         Control userNameTextBox = FindControl(_userNameID);
3755                         if (userNameTextBox is IEditableTextControl) {
3756                             //
3757                             return userNameTextBox;
3758                         } else if (!_createUserWizard.DesignMode) {
3759                             throw new HttpException(SR.GetString(SR.CreateUserWizard_NoUserNameTextBox,
3760                                                                                      _createUserWizard.ID, _userNameID));
3761                         }
3762 
3763                         return null;
3764                     }
3765                 }
3766                 set {
3767                     _userNameTextBox = value;
3768                 }
3769             }
3770         }
3771 
3772         private sealed class CompleteStepContainer : BaseContentTemplateContainer {
3773 
CompleteStepContainer(CreateUserWizard wizard, bool useInnerTable)3774             internal CompleteStepContainer(CreateUserWizard wizard, bool useInnerTable)
3775                 : base(wizard, useInnerTable) {
3776             }
3777 
3778             internal LinkButton ContinueLinkButton { get; set; }
3779 
3780             internal Button ContinuePushButton { get; set; }
3781 
3782             internal ImageButton ContinueImageButton { get; set; }
3783 
3784             internal Image EditProfileIcon { get; set; }
3785 
3786             internal HyperLink EditProfileLink { get; set; }
3787 
3788             internal Table LayoutTable { get; set; }
3789 
3790             internal Literal SuccessTextLabel { get; set; }
3791 
3792             internal Literal Title { get; set; }
3793         }
3794     }
3795 }
3796