2006-12-21 Igor Zelmanovich <igorz@mainsoft.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / CreateUserWizard.cs
1 //
2 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
3 //
4 // Authors:
5 //      Vladimir Krasnov <vladimirk@mainsoft.com>
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26
27 #if NET_2_0
28
29 using System;
30 using System.Web;
31 using System.Web.UI;
32 using System.Web.Security;
33 using System.Collections;
34 using System.ComponentModel;
35 using System.Text;
36
37 namespace System.Web.UI.WebControls
38 {
39         [BindableAttribute (false)]
40         public class CreateUserWizard : Wizard
41         {
42                 public static readonly string ContinueButtonCommandName = "Continue";
43                 private string _password = "";
44                 private string _confirmPassword = "";
45                 private MembershipProvider _provider = null;
46                 private Label _errorMessageLabel = null;
47
48                 private Style _textBoxStyle = null;
49                 private Style _validatorTextStyle = null;
50
51                 private TableItemStyle _completeSuccessTextStyle = null;
52                 private TableItemStyle _errorMessageStyle = null;
53                 private TableItemStyle _hyperLinkStyle = null;
54                 private TableItemStyle _instructionTextStyle = null;
55                 private TableItemStyle _labelStyle = null;
56                 private TableItemStyle _passwordHintStyle = null;
57                 private TableItemStyle _titleTextStyle = null;
58
59                 private static readonly object CreatedUserEvent = new object ();
60                 private static readonly object CreateUserErrorEvent = new object ();
61                 private static readonly object CreatingUserEvent = new object ();
62                 private static readonly object ContinueButtonClickEvent = new object ();
63                 private static readonly object SendingMailEvent = new object ();
64                 private static readonly object SendMailErrorEvent = new object ();
65
66                 private CompleteWizardStep _completeWizardStep = null;
67                 private CreateUserWizardStep _createUserWizardStep = null;
68
69                 public CreateUserWizard ()
70                 {
71                 }
72
73                 #region Public Properties
74
75                 public override int ActiveStepIndex
76                 {
77                         get { return base.ActiveStepIndex; }
78                         set { base.ActiveStepIndex = value; }
79                 }
80
81                 [LocalizableAttribute (true)]
82                 [ThemeableAttribute (false)]
83                 public virtual string Answer
84                 {
85                         get
86                         {
87                                 object o = ViewState ["Answer"];
88                                 return (o == null) ? String.Empty : (string) o;
89                         }
90                         set
91                         {
92                                 if (value == null)
93                                         ViewState.Remove ("Answer");
94                                 else
95                                         ViewState ["Answer"] = value;
96                         }
97                 }
98
99                 [LocalizableAttribute (true)]
100                 public virtual string AnswerLabelText
101                 {
102                         get
103                         {
104                                 object o = ViewState ["AnswerLabelText"];
105                                 return (o == null) ? Locale.GetText ("Security Answer:") : (string) o;
106                         }
107                         set
108                         {
109                                 if (value == null)
110                                         ViewState.Remove ("AnswerLabelText");
111                                 else
112                                         ViewState ["AnswerLabelText"] = value;
113                         }
114                 }
115
116                 [LocalizableAttribute (true)]
117                 public virtual string AnswerRequiredErrorMessage
118                 {
119                         get
120                         {
121                                 object o = ViewState ["AnswerRequiredErrorMessage"];
122                                 return (o == null) ? Locale.GetText ("Security answer is required.") : (string) o;
123                         }
124                         set
125                         {
126                                 if (value == null)
127                                         ViewState.Remove ("AnswerRequiredErrorMessage");
128                                 else
129                                         ViewState ["AnswerRequiredErrorMessage"] = value;
130                         }
131                 }
132
133                 [ThemeableAttribute (false)]
134                 public virtual bool AutoGeneratePassword
135                 {
136                         get
137                         {
138                                 object o = ViewState ["AutoGeneratePassword"];
139                                 return (o == null) ? false : (bool) o;
140                         }
141                         set
142                         {
143                                 ViewState ["AutoGeneratePassword"] = value;
144                         }
145                 }
146
147                 public CompleteWizardStep CompleteStep
148                 {
149                         get
150                         {
151                                 if (_completeWizardStep == null) {
152                                         for (int i = 0; i < WizardSteps.Count; i++)
153                                                 if (WizardSteps [i] is CompleteWizardStep) {
154                                                         _completeWizardStep = (CompleteWizardStep) WizardSteps [i];
155
156                                                         if (_completeWizardStep.Wizard == null)
157                                                                 _completeWizardStep.SetWizard (this);
158                                                 }
159                                 }
160                                 return _completeWizardStep;
161                         }
162                 }
163
164                 [LocalizableAttribute (true)]
165                 public virtual string CompleteSuccessText
166                 {
167                         get
168                         {
169                                 object o = ViewState ["CompleteSuccessText"];
170                                 return (o == null) ? Locale.GetText ("Your account has been successfully created.") : (string) o;
171                         }
172                         set
173                         {
174                                 if (value == null)
175                                         ViewState.Remove ("CompleteSuccessText");
176                                 else
177                                         ViewState ["CompleteSuccessText"] = value;
178                         }
179                 }
180
181                 public TableItemStyle CompleteSuccessTextStyle
182                 {
183                         get
184                         {
185                                 if (_completeSuccessTextStyle == null) {
186                                         _completeSuccessTextStyle = new TableItemStyle ();
187                                         if (IsTrackingViewState)
188                                                 ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
189                                 }
190                                 return _completeSuccessTextStyle;
191                         }
192                 }
193
194                 public virtual string ConfirmPassword
195                 {
196                         get { return _confirmPassword; }
197                 }
198
199                 [LocalizableAttribute (true)]
200                 public virtual string ConfirmPasswordCompareErrorMessage
201                 {
202                         get
203                         {
204                                 object o = ViewState ["ConfirmPasswordCompareErrorMessage"];
205                                 return (o == null) ? Locale.GetText ("The Password and Confirmation Password must match.") : (string) o;
206                         }
207                         set
208                         {
209                                 if (value == null)
210                                         ViewState.Remove ("ConfirmPasswordCompareErrorMessage");
211                                 else
212                                         ViewState ["ConfirmPasswordCompareErrorMessage"] = value;
213                         }
214                 }
215
216                 [LocalizableAttribute (true)]
217                 public virtual string ConfirmPasswordLabelText
218                 {
219                         get
220                         {
221                                 object o = ViewState ["ConfirmPasswordLabelText"];
222                                 return (o == null) ? Locale.GetText ("Confirm Password:") : (string) o;
223                         }
224                         set
225                         {
226                                 if (value == null)
227                                         ViewState.Remove ("ConfirmPasswordLabelText");
228                                 else
229                                         ViewState ["ConfirmPasswordLabelText"] = value;
230                         }
231                 }
232
233                 [LocalizableAttribute (true)]
234                 public virtual string ConfirmPasswordRequiredErrorMessage
235                 {
236                         get
237                         {
238                                 object o = ViewState ["ConfirmPasswordRequiredErrorMessage"];
239                                 return (o == null) ? Locale.GetText ("Confirm Password is required.") : (string) o;
240                         }
241                         set
242                         {
243                                 if (value == null)
244                                         ViewState.Remove ("ConfirmPasswordRequiredErrorMessage");
245                                 else
246                                         ViewState ["ConfirmPasswordRequiredErrorMessage"] = value;
247                         }
248                 }
249
250                 public virtual string ContinueButtonImageUrl
251                 {
252                         get { return base.FinishCompleteButtonImageUrl; }
253                         set { base.FinishCompleteButtonImageUrl = value; }
254                 }
255
256                 public Style ContinueButtonStyle
257                 {
258                         get
259                         {
260                                 return base.FinishCompleteButtonStyle;
261                         }
262                 }
263
264                 [LocalizableAttribute (true)]
265                 public virtual string ContinueButtonText
266                 {
267                         get
268                         {
269                                 object o = ViewState ["ContinueButtonText"];
270                                 return (o == null) ? Locale.GetText ("Continue") : (string) o;
271                         }
272                         set
273                         {
274                                 if (value == null)
275                                         ViewState.Remove ("ContinueButtonText");
276                                 else
277                                         ViewState ["ContinueButtonText"] = value;
278                         }
279                 }
280
281                 [MonoTODO ("This should be saved to viewstate")]
282                 public virtual ButtonType ContinueButtonType
283                 {
284                         get { return base.FinishCompleteButtonType; }
285                         set { base.FinishCompleteButtonType = value; }
286                 }
287
288                 [ThemeableAttribute (false)]
289                 public virtual string ContinueDestinationPageUrl
290                 {
291                         get
292                         {
293                                 object o = ViewState ["ContinueDestinationPageUrl"];
294                                 return (o == null) ? "" : (string) o;
295                         }
296                         set
297                         {
298                                 if (value == null)
299                                         ViewState.Remove ("ContinueDestinationPageUrl");
300                                 else
301                                         ViewState ["ContinueDestinationPageUrl"] = value;
302                         }
303                 }
304
305                 public virtual string CreateUserButtonImageUrl
306                 {
307                         get { return base.StartNextButtonImageUrl; }
308                         set { StartNextButtonImageUrl = value; }
309                 }
310
311                 public Style CreateUserButtonStyle
312                 {
313                         get
314                         {
315                                 return base.StartNextButtonStyle;
316                         }
317                 }
318
319                 [LocalizableAttribute (true)]
320                 public virtual string CreateUserButtonText
321                 {
322                         get
323                         {
324                                 object o = ViewState ["CreateUserButtonText"];
325                                 return (o == null) ? Locale.GetText ("Create User") : (string) o;
326                         }
327                         set
328                         {
329                                 if (value == null)
330                                         ViewState.Remove ("CreateUserButtonText");
331                                 else
332                                         ViewState ["CreateUserButtonText"] = value;
333                         }
334                 }
335
336                 [MonoTODO ("This should be saved to viewstate")]
337                 public virtual ButtonType CreateUserButtonType
338                 {
339                         get { return base.StartNextButtonType; }
340                         set { base.StartNextButtonType = value; }
341                 }
342
343                 public CreateUserWizardStep CreateUserStep
344                 {
345                         get
346                         {
347                                 if (_createUserWizardStep == null) {
348                                         for (int i = 0; i < WizardSteps.Count; i++)
349                                                 if (WizardSteps [i] is CreateUserWizardStep) {
350                                                         _createUserWizardStep = (CreateUserWizardStep) WizardSteps [i];
351
352                                                         if (_createUserWizardStep.Wizard == null)
353                                                                 _createUserWizardStep.SetWizard (this);
354                                                 }
355                                 }
356                                 return _createUserWizardStep;
357                         }
358                 }
359
360                 [ThemeableAttribute (false)]
361                 public virtual bool DisableCreatedUser
362                 {
363                         get
364                         {
365                                 object o = ViewState ["DisableCreatedUser"];
366                                 return (o == null) ? false : (bool) o;
367                         }
368                         set
369                         {
370                                 ViewState ["DisableCreatedUser"] = value;
371                         }
372                 }
373
374                 public override bool DisplaySideBar
375                 {
376                         get {
377                                 return ViewState.GetBool ("DisplaySideBar", false);
378                         }
379                         set {
380                                 ViewState ["DisplaySideBar"] = value;
381                                 ChildControlsCreated = false;
382                         }
383                 }
384
385                 [LocalizableAttribute (true)]
386                 public virtual string DuplicateEmailErrorMessage
387                 {
388                         get
389                         {
390                                 object o = ViewState ["DuplicateEmailErrorMessage"];
391                                 return (o == null) ? Locale.GetText ("The e-mail address that you entered is already in use. Please enter a different e-mail address.") : (string) o;
392                         }
393                         set
394                         {
395                                 if (value == null)
396                                         ViewState.Remove ("DuplicateEmailErrorMessage");
397                                 else
398                                         ViewState ["DuplicateEmailErrorMessage"] = value;
399                         }
400                 }
401
402                 [LocalizableAttribute (true)]
403                 public virtual string DuplicateUserNameErrorMessage
404                 {
405                         get
406                         {
407                                 object o = ViewState ["DuplicateUserNameErrorMessage"];
408                                 return (o == null) ? Locale.GetText ("Please enter a different user name.") : (string) o;
409                         }
410                         set
411                         {
412                                 if (value == null)
413                                         ViewState.Remove ("DuplicateUserNameErrorMessage");
414                                 else
415                                         ViewState ["DuplicateUserNameErrorMessage"] = value;
416                         }
417                 }
418
419                 public virtual string EditProfileIconUrl
420                 {
421                         get
422                         {
423                                 object o = ViewState ["EditProfileIconUrl"];
424                                 return (o == null) ? "" : (string) o;
425                         }
426                         set
427                         {
428                                 if (value == null)
429                                         ViewState.Remove ("EditProfileIconUrl");
430                                 else
431                                         ViewState ["EditProfileIconUrl"] = value;
432                         }
433                 }
434
435                 [LocalizableAttribute (true)]
436                 public virtual string EditProfileText
437                 {
438                         get
439                         {
440                                 object o = ViewState ["EditProfileText"];
441                                 return (o == null) ? "" : (string) o;
442                         }
443                         set
444                         {
445                                 if (value == null)
446                                         ViewState.Remove ("EditProfileText");
447                                 else
448                                         ViewState ["EditProfileText"] = value;
449                         }
450                 }
451
452                 public virtual string EditProfileUrl
453                 {
454                         get
455                         {
456                                 object o = ViewState ["EditProfileUrl"];
457                                 return (o == null) ? "" : (string) o;
458                         }
459                         set
460                         {
461                                 if (value == null)
462                                         ViewState.Remove ("EditProfileUrl");
463                                 else
464                                         ViewState ["EditProfileUrl"] = value;
465                         }
466                 }
467
468                 public virtual string Email
469                 {
470                         get
471                         {
472                                 object o = ViewState ["Email"];
473                                 return (o == null) ? String.Empty : (string) o;
474                         }
475                         set
476                         {
477                                 if (value == null)
478                                         ViewState.Remove ("Email");
479                                 else
480                                         ViewState ["Email"] = value;
481                         }
482                 }
483
484                 [LocalizableAttribute (true)]
485                 public virtual string EmailLabelText
486                 {
487                         get
488                         {
489                                 object o = ViewState ["EmailLabelText"];
490                                 return (o == null) ? Locale.GetText ("E-mail:") : (string) o;
491                         }
492                         set
493                         {
494                                 if (value == null)
495                                         ViewState.Remove ("EmailLabelText");
496                                 else
497                                         ViewState ["EmailLabelText"] = value;
498                         }
499                 }
500
501                 public virtual string EmailRegularExpression
502                 {
503                         get
504                         {
505                                 object o = ViewState ["EmailRegularExpression"];
506                                 return (o == null) ? "" : (string) o;
507                         }
508                         set
509                         {
510                                 if (value == null)
511                                         ViewState.Remove ("EmailRegularExpression");
512                                 else
513                                         ViewState ["EmailRegularExpression"] = value;
514                         }
515                 }
516
517                 public virtual string EmailRegularExpressionErrorMessage
518                 {
519                         get
520                         {
521                                 object o = ViewState ["EmailRegularExpressionErrorMessage"];
522                                 return (o == null) ? Locale.GetText ("Please enter a different e-mail.") : (string) o;
523                         }
524                         set
525                         {
526                                 if (value == null)
527                                         ViewState.Remove ("EmailRegularExpressionErrorMessage");
528                                 else
529                                         ViewState ["EmailRegularExpressionErrorMessage"] = value;
530                         }
531                 }
532
533                 [LocalizableAttribute (true)]
534                 public virtual string EmailRequiredErrorMessage
535                 {
536                         get
537                         {
538                                 object o = ViewState ["EmailRequiredErrorMessage"];
539                                 return (o == null) ? Locale.GetText ("E-mail is required.") : (string) o;
540                         }
541                         set
542                         {
543                                 if (value == null)
544                                         ViewState.Remove ("EmailRequiredErrorMessage");
545                                 else
546                                         ViewState ["EmailRequiredErrorMessage"] = value;
547                         }
548                 }
549
550                 public TableItemStyle ErrorMessageStyle
551                 {
552                         get
553                         {
554                                 if (_errorMessageStyle == null) {
555                                         _errorMessageStyle = new TableItemStyle ();
556                                         if (IsTrackingViewState)
557                                                 ((IStateManager) _errorMessageStyle).TrackViewState ();
558                                 }
559                                 return _errorMessageStyle;
560                         }
561                 }
562
563                 public virtual string HelpPageIconUrl
564                 {
565                         get
566                         {
567                                 object o = ViewState ["HelpPageIconUrl"];
568                                 return (o == null) ? "" : (string) o;
569                         }
570                         set
571                         {
572                                 if (value == null)
573                                         ViewState.Remove ("HelpPageIconUrl");
574                                 else
575                                         ViewState ["HelpPageIconUrl"] = value;
576                         }
577                 }
578
579                 [LocalizableAttribute (true)]
580                 public virtual string HelpPageText
581                 {
582                         get
583                         {
584                                 object o = ViewState ["HelpPageText"];
585                                 return (o == null) ? "" : (string) o;
586                         }
587                         set
588                         {
589                                 if (value == null)
590                                         ViewState.Remove ("HelpPageText");
591                                 else
592                                         ViewState ["HelpPageText"] = value;
593                         }
594                 }
595
596                 public virtual string HelpPageUrl
597                 {
598                         get
599                         {
600                                 object o = ViewState ["HelpPageUrl"];
601                                 return (o == null) ? "" : (string) o;
602                         }
603                         set
604                         {
605                                 if (value == null)
606                                         ViewState.Remove ("HelpPageUrl");
607                                 else
608                                         ViewState ["HelpPageUrl"] = value;
609                         }
610                 }
611
612                 public TableItemStyle HyperLinkStyle
613                 {
614                         get
615                         {
616                                 if (_hyperLinkStyle == null) {
617                                         _hyperLinkStyle = new TableItemStyle ();
618                                         if (IsTrackingViewState)
619                                                 ((IStateManager) _hyperLinkStyle).TrackViewState ();
620                                 }
621                                 return _hyperLinkStyle;
622                         }
623                 }
624
625                 [LocalizableAttribute (true)]
626                 public virtual string InstructionText
627                 {
628                         get
629                         {
630                                 object o = ViewState ["InstructionText"];
631                                 return (o == null) ? "" : (string) o;
632                         }
633                         set
634                         {
635                                 if (value == null)
636                                         ViewState.Remove ("InstructionText");
637                                 else
638                                         ViewState ["InstructionText"] = value;
639                         }
640                 }
641
642                 public TableItemStyle InstructionTextStyle
643                 {
644                         get
645                         {
646                                 if (_instructionTextStyle == null) {
647                                         _instructionTextStyle = new TableItemStyle ();
648                                         if (IsTrackingViewState)
649                                                 ((IStateManager) _instructionTextStyle).TrackViewState ();
650                                 }
651                                 return _instructionTextStyle;
652                         }
653                 }
654
655                 [LocalizableAttribute (true)]
656                 public virtual string InvalidAnswerErrorMessage
657                 {
658                         get
659                         {
660                                 object o = ViewState ["InvalidAnswerErrorMessage"];
661                                 return (o == null) ? Locale.GetText ("Please enter a different security answer.") : (string) o;
662                         }
663                         set
664                         {
665                                 if (value == null)
666                                         ViewState.Remove ("InvalidAnswerErrorMessage");
667                                 else
668                                         ViewState ["InvalidAnswerErrorMessage"] = value;
669                         }
670                 }
671
672                 [LocalizableAttribute (true)]
673                 public virtual string InvalidEmailErrorMessage
674                 {
675                         get
676                         {
677                                 object o = ViewState ["InvalidEmailErrorMessage"];
678                                 return (o == null) ? Locale.GetText ("Please enter a valid e-mail address.") : (string) o;
679                         }
680                         set
681                         {
682                                 if (value == null)
683                                         ViewState.Remove ("InvalidEmailErrorMessage");
684                                 else
685                                         ViewState ["InvalidEmailErrorMessage"] = value;
686                         }
687                 }
688
689                 [MonoTODO ("take the values from membership provider")]
690                 [LocalizableAttribute (true)]
691                 public virtual string InvalidPasswordErrorMessage
692                 {
693                         get
694                         {
695                                 object o = ViewState ["InvalidPasswordErrorMessage"];
696                                 return (o == null) ? Locale.GetText ("Password length minimum: {0}. Non-alphanumeric characters required: {1}.") : (string) o;
697                         }
698                         set
699                         {
700                                 if (value == null)
701                                         ViewState.Remove ("InvalidPasswordErrorMessage");
702                                 else
703                                         ViewState ["InvalidPasswordErrorMessage"] = value;
704                         }
705                 }
706
707                 [LocalizableAttribute (true)]
708                 public virtual string InvalidQuestionErrorMessage
709                 {
710                         get
711                         {
712                                 object o = ViewState ["InvalidQuestionErrorMessage"];
713                                 return (o == null) ? Locale.GetText ("Please enter a different security question.") : (string) o;
714                         }
715                         set
716                         {
717                                 if (value == null)
718                                         ViewState.Remove ("InvalidQuestionErrorMessage");
719                                 else
720                                         ViewState ["InvalidQuestionErrorMessage"] = value;
721                         }
722                 }
723
724                 public TableItemStyle LabelStyle
725                 {
726                         get
727                         {
728                                 if (_labelStyle == null) {
729                                         _labelStyle = new TableItemStyle ();
730                                         if (IsTrackingViewState)
731                                                 ((IStateManager) _labelStyle).TrackViewState ();
732                                 }
733                                 return _labelStyle;
734                         }
735                 }
736
737                 [ThemeableAttribute (false)]
738                 public virtual bool LoginCreatedUser
739                 {
740                         get
741                         {
742                                 object o = ViewState ["LoginCreatedUser"];
743                                 return (o == null) ? true : (bool) o;
744                         }
745                         set
746                         {
747                                 ViewState ["LoginCreatedUser"] = value;
748                         }
749                 }
750
751                 //[MonoTODO ("Sending mail functionality is not implemented")]
752                 //[ThemeableAttribute (false)]
753                 //public MailDefinition MailDefinition
754                 //{
755                 //      get { throw new NotImplementedException (); }
756                 //}
757
758                 [ThemeableAttribute (false)]
759                 public virtual string MembershipProvider
760                 {
761                         get
762                         {
763                                 object o = ViewState ["MembershipProvider"];
764                                 return (o == null) ? "" : (string) o;
765                         }
766                         set
767                         {
768                                 if (value == null)
769                                         ViewState.Remove ("MembershipProvider");
770                                 else
771                                         ViewState ["MembershipProvider"] = value;
772
773                                 _provider = null;
774                         }
775                 }
776
777                 internal virtual MembershipProvider MembershipProviderInternal
778                 {
779                         get
780                         {
781                                 if (_provider == null)
782                                         InitMemberShipProvider ();
783
784                                 return _provider;
785                         }
786                 }
787
788                 public virtual string Password
789                 {
790                         get { return _password; }
791                 }
792
793                 public TableItemStyle PasswordHintStyle
794                 {
795                         get
796                         {
797                                 if (_passwordHintStyle == null) {
798                                         _passwordHintStyle = new TableItemStyle ();
799                                         if (IsTrackingViewState)
800                                                 ((IStateManager) _passwordHintStyle).TrackViewState ();
801                                 }
802                                 return _passwordHintStyle;
803                         }
804                 }
805
806                 [LocalizableAttribute (true)]
807                 public virtual string PasswordHintText
808                 {
809                         get
810                         {
811                                 object o = ViewState ["PasswordHintText"];
812                                 return (o == null) ? "" : (string) o;
813                         }
814                         set
815                         {
816                                 if (value == null)
817                                         ViewState.Remove ("PasswordHintText");
818                                 else
819                                         ViewState ["PasswordHintText"] = value;
820                         }
821                 }
822
823                 [LocalizableAttribute (true)]
824                 public virtual string PasswordLabelText
825                 {
826                         get
827                         {
828                                 object o = ViewState ["PasswordLabelText"];
829                                 return (o == null) ? Locale.GetText ("Password:") : (string) o;
830                         }
831                         set
832                         {
833                                 if (value == null)
834                                         ViewState.Remove ("PasswordLabelText");
835                                 else
836                                         ViewState ["PasswordLabelText"] = value;
837                         }
838                 }
839
840                 public virtual string PasswordRegularExpression
841                 {
842                         get
843                         {
844                                 object o = ViewState ["PasswordRegularExpression"];
845                                 return (o == null) ? "" : (string) o;
846                         }
847                         set
848                         {
849                                 if (value == null)
850                                         ViewState.Remove ("PasswordRegularExpression");
851                                 else
852                                         ViewState ["PasswordRegularExpression"] = value;
853                         }
854                 }
855
856                 public virtual string PasswordRegularExpressionErrorMessage
857                 {
858                         get
859                         {
860                                 object o = ViewState ["PasswordRegularExpressionErrorMessage"];
861                                 return (o == null) ? Locale.GetText ("Please enter a different password.") : (string) o;
862                         }
863                         set
864                         {
865                                 if (value == null)
866                                         ViewState.Remove ("PasswordRegularExpressionErrorMessage");
867                                 else
868                                         ViewState ["PasswordRegularExpressionErrorMessage"] = value;
869                         }
870                 }
871
872                 [LocalizableAttribute (true)]
873                 public virtual string PasswordRequiredErrorMessage
874                 {
875                         get
876                         {
877                                 object o = ViewState ["PasswordRequiredErrorMessage"];
878                                 return (o == null) ? Locale.GetText ("Password is required.") : (string) o;
879                         }
880                         set
881                         {
882                                 if (value == null)
883                                         ViewState.Remove ("PasswordRequiredErrorMessage");
884                                 else
885                                         ViewState ["PasswordRequiredErrorMessage"] = value;
886                         }
887                 }
888
889                 [LocalizableAttribute (true)]
890                 [ThemeableAttribute (false)]
891                 public virtual string Question
892                 {
893                         get
894                         {
895                                 object o = ViewState ["Question"];
896                                 return (o == null) ? String.Empty : (string) o;
897                         }
898                         set
899                         {
900                                 if (value == null)
901                                         ViewState.Remove ("Question");
902                                 else
903                                         ViewState ["Question"] = value;
904                         }
905                 }
906
907                 [LocalizableAttribute (true)]
908                 public virtual string QuestionLabelText
909                 {
910                         get
911                         {
912                                 object o = ViewState ["QuestionLabelText"];
913                                 return (o == null) ? Locale.GetText ("Security Question:") : (string) o;
914                         }
915                         set
916                         {
917                                 if (value == null)
918                                         ViewState.Remove ("QuestionLabelText");
919                                 else
920                                         ViewState ["QuestionLabelText"] = value;
921                         }
922                 }
923
924                 [LocalizableAttribute (true)]
925                 public virtual string QuestionRequiredErrorMessage
926                 {
927                         get
928                         {
929                                 object o = ViewState ["QuestionRequiredErrorMessage"];
930                                 return (o == null) ? Locale.GetText ("Security question is required.") : (string) o;
931                         }
932                         set
933                         {
934                                 if (value == null)
935                                         ViewState.Remove ("QuestionRequiredErrorMessage");
936                                 else
937                                         ViewState ["QuestionRequiredErrorMessage"] = value;
938                         }
939                 }
940
941                 [ThemeableAttribute (false)]
942                 public virtual bool RequireEmail
943                 {
944                         get
945                         {
946                                 object o = ViewState ["RequireEmail"];
947                                 return (o == null) ? true : (bool) o;
948                         }
949                         set
950                         {
951                                 ViewState ["RequireEmail"] = value;
952                         }
953                 }
954
955                 [MonoTODO ("doesnt work")]
956                 public override string SkipLinkText
957                 {
958                         get
959                         {
960                                 object o = ViewState ["SkipLinkText"];
961                                 return (o == null) ? "" : (string) o;
962                         }
963                         set
964                         {
965                                 if (value == null)
966                                         ViewState.Remove ("SkipLinkText");
967                                 else
968                                         ViewState ["SkipLinkText"] = value;
969                         }
970                 }
971
972                 public Style TextBoxStyle
973                 {
974                         get
975                         {
976                                 if (_textBoxStyle == null) {
977                                         _textBoxStyle = new Style ();
978                                         if (IsTrackingViewState)
979                                                 ((IStateManager) _textBoxStyle).TrackViewState ();
980                                 }
981                                 return _textBoxStyle;
982                         }
983                 }
984
985                 public TableItemStyle TitleTextStyle
986                 {
987                         get
988                         {
989                                 if (_titleTextStyle == null) {
990                                         _titleTextStyle = new TableItemStyle ();
991                                         if (IsTrackingViewState)
992                                                 ((IStateManager) _titleTextStyle).TrackViewState ();
993                                 }
994                                 return _titleTextStyle;
995                         }
996                 }
997
998                 [LocalizableAttribute (true)]
999                 public virtual string UnknownErrorMessage
1000                 {
1001                         get
1002                         {
1003                                 object o = ViewState ["UnknownErrorMessage"];
1004                                 return (o == null) ? Locale.GetText ("Your account was not created. Please try again.") : (string) o;
1005                         }
1006                         set
1007                         {
1008                                 if (value == null)
1009                                         ViewState.Remove ("UnknownErrorMessage");
1010                                 else
1011                                         ViewState ["UnknownErrorMessage"] = value;
1012                         }
1013                 }
1014
1015                 public virtual string UserName
1016                 {
1017                         get
1018                         {
1019                                 object o = ViewState ["UserName"];
1020                                 return (o == null) ? String.Empty : (string) o;
1021                         }
1022                         set
1023                         {
1024                                 if (value == null)
1025                                         ViewState.Remove ("UserName");
1026                                 else
1027                                         ViewState ["UserName"] = value;
1028                         }
1029                 }
1030
1031                 [LocalizableAttribute (true)]
1032                 public virtual string UserNameLabelText
1033                 {
1034                         get
1035                         {
1036                                 object o = ViewState ["UserNameLabelText"];
1037                                 return (o == null) ? Locale.GetText ("User Name:") : (string) o;
1038                         }
1039                         set
1040                         {
1041                                 if (value == null)
1042                                         ViewState.Remove ("UserNameLabelText");
1043                                 else
1044                                         ViewState ["UserNameLabelText"] = value;
1045                         }
1046                 }
1047
1048                 [LocalizableAttribute (true)]
1049                 public virtual string UserNameRequiredErrorMessage
1050                 {
1051                         get
1052                         {
1053                                 object o = ViewState ["UserNameRequiredErrorMessage"];
1054                                 return (o == null) ? Locale.GetText ("User Name is required.") : (string) o;
1055                         }
1056                         set
1057                         {
1058                                 if (value == null)
1059                                         ViewState.Remove ("UserNameRequiredErrorMessage");
1060                                 else
1061                                         ViewState ["UserNameRequiredErrorMessage"] = value;
1062                         }
1063                 }
1064
1065                 public Style ValidatorTextStyle
1066                 {
1067                         get
1068                         {
1069                                 if (_validatorTextStyle == null) {
1070                                         _validatorTextStyle = new Style ();
1071                                         if (IsTrackingViewState)
1072                                                 ((IStateManager) _validatorTextStyle).TrackViewState ();
1073                                 }
1074                                 return _validatorTextStyle;
1075                         }
1076                 }
1077
1078                 [ThemeableAttribute (false)]
1079                 public override WizardStepCollection WizardSteps
1080                 {
1081                         get { return base.WizardSteps; }
1082                 }
1083
1084                 #endregion
1085
1086                 #region Protected Properties
1087
1088                 protected internal bool QuestionAndAnswerRequired
1089                 {
1090                         get { return MembershipProviderInternal.RequiresQuestionAndAnswer; }
1091                 }
1092
1093                 public event EventHandler ContinueButtonClick
1094                 {
1095                         add { Events.AddHandler (ContinueButtonClickEvent, value); }
1096                         remove { Events.RemoveHandler (ContinueButtonClickEvent, value); }
1097                 }
1098
1099                 public event EventHandler CreatedUser
1100                 {
1101                         add { Events.AddHandler (CreatedUserEvent, value); }
1102                         remove { Events.RemoveHandler (CreatedUserEvent, value); }
1103                 }
1104
1105                 public event CreateUserErrorEventHandler CreateUserError
1106                 {
1107                         add { Events.AddHandler (CreateUserErrorEvent, value); }
1108                         remove { Events.RemoveHandler (CreateUserErrorEvent, value); }
1109                 }
1110
1111                 public event LoginCancelEventHandler CreatingUser
1112                 {
1113                         add { Events.AddHandler (CreatingUserEvent, value); }
1114                         remove { Events.RemoveHandler (CreatingUserEvent, value); }
1115                 }
1116
1117                 public event MailMessageEventHandler SendingMail
1118                 {
1119                         add { Events.AddHandler (SendingMailEvent, value); }
1120                         remove { Events.RemoveHandler (SendingMailEvent, value); }
1121                 }
1122
1123                 public event SendMailErrorEventHandler SendMailError
1124                 {
1125                         add { Events.AddHandler (SendMailErrorEvent, value); }
1126                         remove { Events.RemoveHandler (SendMailErrorEvent, value); }
1127                 }
1128
1129
1130                 #endregion
1131
1132                 #region Internal Properties
1133
1134                 internal override void InstantiateTemplateStep (TemplatedWizardStep step)
1135                 {
1136                         if (step is CreateUserWizardStep) {
1137                                 InstantiateCreateUserWizardStep ((CreateUserWizardStep) step);
1138                         }
1139                         else if (step is CompleteWizardStep) {
1140                                 InstantiateCompleteWizardStep ((CompleteWizardStep) step);
1141                         }
1142                         else {
1143                                 base.InstantiateTemplateStep (step);
1144                         }
1145                 }
1146
1147                 private void InstantiateCompleteWizardStep (CompleteWizardStep step)
1148                 {
1149                         BaseWizardContainer contentTemplateContainer = new BaseWizardContainer ();
1150                         contentTemplateContainer.InstatiateTemplate (step.ContentTemplate != null ? step.ContentTemplate : new CompleteStepTemplate (this));
1151
1152                         step.ContentTemplateContainer = contentTemplateContainer;
1153                         step.Controls.Clear ();
1154                         step.Controls.Add (contentTemplateContainer);
1155
1156                         BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
1157                         if (step.CustomNavigationTemplate != null) {
1158                                 step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
1159                                 RegisterCustomNavigation (step, customNavigationTemplateContainer);
1160                         }
1161                         step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
1162                 }
1163
1164                 void InstantiateCreateUserWizardStep (CreateUserWizardStep step)
1165                 {
1166                         BaseWizardContainer contentTemplateContainer = new CreateUserStepContainer ();
1167                         contentTemplateContainer.InstatiateTemplate (step.ContentTemplate != null ? step.ContentTemplate : new CreateUserStepTemplate (this));
1168
1169                         step.ContentTemplateContainer = contentTemplateContainer;
1170                         step.Controls.Clear ();
1171                         step.Controls.Add (contentTemplateContainer);
1172
1173                         BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
1174                         (step.CustomNavigationTemplate != null ? step.CustomNavigationTemplate : new CreateUserStepNavigationTemplate (this)).InstantiateIn (customNavigationTemplateContainer);
1175                         RegisterCustomNavigation (step, customNavigationTemplateContainer);
1176
1177                         step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
1178                 }
1179                 
1180                 internal override ITemplate SideBarItemTemplate
1181                 {
1182                         get { return new SideBarLabelTemplate (this); }
1183                 }
1184
1185                 #endregion
1186
1187                 #region Protected Methods
1188
1189                 protected internal override void CreateChildControls ()
1190                 {
1191                         CreateUserWizardStep c = CreateUserStep;
1192
1193                         base.CreateChildControls ();
1194                 }
1195
1196                 protected override void CreateControlHierarchy ()
1197                 {
1198                         base.CreateControlHierarchy ();
1199
1200                         CreateUserStepContainer container = CreateUserStep.ContentTemplateContainer as CreateUserStepContainer;
1201
1202                         if (container != null) {
1203                                 IEditableTextControl editable;
1204                                 editable = container.UserNameTextBox as IEditableTextControl;
1205
1206                                 if (editable != null)
1207                                         editable.TextChanged += new EventHandler (UserName_TextChanged);
1208
1209                                 if (!AutoGeneratePassword) {
1210                                         editable = container.PasswordTextBox as IEditableTextControl;
1211
1212                                         if (editable != null)
1213                                                 editable.TextChanged += new EventHandler (Password_TextChanged);
1214
1215                                         editable = container.ConfirmPasswordTextBox as IEditableTextControl;
1216
1217                                         if (editable != null)
1218                                                 editable.TextChanged += new EventHandler (ConfirmPassword_TextChanged);
1219                                 }
1220
1221                                 if (RequireEmail) {
1222                                         editable = container.EmailTextBox as IEditableTextControl;
1223
1224                                         if (editable != null)
1225                                                 editable.TextChanged += new EventHandler (Email_TextChanged);
1226                                 }
1227
1228                                 if (QuestionAndAnswerRequired) {
1229                                         editable = container.QuestionTextBox as IEditableTextControl;
1230
1231                                         if (editable != null)
1232                                                 editable.TextChanged += new EventHandler (Question_TextChanged);
1233
1234                                         editable = container.AnswerTextBox as IEditableTextControl;
1235
1236                                         if (editable != null)
1237                                                 editable.TextChanged += new EventHandler (Answer_TextChanged);
1238                                 }
1239
1240                                 _errorMessageLabel = container.ErrorMessageLabel;
1241                         }
1242                 }
1243
1244                 [MonoTODO ("Not Implemented")]
1245                 protected override IDictionary GetDesignModeState ()
1246                 {
1247                         throw new NotImplementedException ();
1248                 }
1249
1250                 protected internal override void OnInit (EventArgs e)
1251                 {
1252                         base.OnInit (e);
1253
1254                         if (CreateUserStep == null)
1255                                 WizardSteps.AddAt (0, new CreateUserWizardStep ());
1256
1257                         if (CompleteStep == null)
1258                                 WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
1259
1260                         if (ActiveStepIndex < 0)
1261                                 ActiveStepIndex = 0;
1262                 }
1263
1264                 protected override bool OnBubbleEvent (object source, EventArgs e)
1265                 {
1266                         CommandEventArgs args = e as CommandEventArgs;
1267                         if (e != null && args.CommandName == ContinueButtonCommandName) {
1268                                 ProcessContinueEvent ();
1269                                 return true;
1270                         }
1271                         return base.OnBubbleEvent (source, e);
1272                 }
1273
1274                 private void ProcessContinueEvent () {
1275                         OnContinueButtonClick (EventArgs.Empty);
1276
1277                         if (ContinueDestinationPageUrl.Length > 0) {
1278                                 Context.Response.Redirect (ContinueDestinationPageUrl);
1279                         }
1280                 }
1281
1282                 protected virtual void OnContinueButtonClick (EventArgs e)
1283                 {
1284                         if (Events != null) {
1285                                 EventHandler eh = (EventHandler) Events [ContinueButtonClickEvent];
1286                                 if (eh != null) eh (this, e);
1287                         }
1288                 }
1289
1290                 protected virtual void OnCreatedUser (EventArgs e)
1291                 {
1292                         if (Events != null) {
1293                                 EventHandler eh = (EventHandler) Events [CreatedUserEvent];
1294                                 if (eh != null) eh (this, e);
1295                         }
1296                 }
1297
1298                 protected virtual void OnCreateUserError (CreateUserErrorEventArgs e)
1299                 {
1300                         if (Events != null) {
1301                                 CreateUserErrorEventHandler eh = (CreateUserErrorEventHandler) Events [CreateUserErrorEvent];
1302                                 if (eh != null) eh (this, e);
1303                         }
1304                 }
1305
1306                 protected virtual void OnCreatingUser (LoginCancelEventArgs e)
1307                 {
1308                         if (Events != null) {
1309                                 LoginCancelEventHandler eh = (LoginCancelEventHandler) Events [CreatingUserEvent];
1310                                 if (eh != null) eh (this, e);
1311                         }
1312                 }
1313
1314                 protected override void OnNextButtonClick (WizardNavigationEventArgs e)
1315                 {
1316                         if (ActiveStep == CreateUserStep) {
1317                                 bool userCreated = CreateUser ();
1318                                 if (!userCreated)
1319                                         e.Cancel = true;
1320                                 else
1321                                         if (LoginCreatedUser)
1322                                                 Login ();
1323                         }
1324                         base.OnNextButtonClick (e);
1325                 }
1326
1327                 protected internal override void OnPreRender (EventArgs e)
1328                 {
1329                         base.OnPreRender (e);
1330                 }
1331
1332                 protected virtual void OnSendingMail (MailMessageEventArgs e)
1333                 {
1334                         if (Events != null) {
1335                                 MailMessageEventHandler eh = (MailMessageEventHandler) Events [SendingMailEvent];
1336                                 if (eh != null) eh (this, e);
1337                         }
1338                 }
1339
1340                 protected virtual void OnSendMailError (SendMailErrorEventArgs e)
1341                 {
1342                         if (Events != null) {
1343                                 SendMailErrorEventHandler eh = (SendMailErrorEventHandler) Events [SendMailErrorEvent];
1344                                 if (eh != null) eh (this, e);
1345                         }
1346                 }
1347
1348                 protected override void LoadViewState (object savedState)
1349                 {
1350                         if (savedState == null) {
1351                                 base.LoadViewState (null);
1352                                 return;
1353                         }
1354
1355                         object [] states = (object []) savedState;
1356                         base.LoadViewState (states [0]);
1357
1358                         if (states [1] != null) ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
1359                         if (states [2] != null) ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
1360                         if (states [3] != null) ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
1361                         if (states [4] != null) ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
1362                         if (states [5] != null) ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
1363                         if (states [6] != null) ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
1364                         if (states [7] != null) ((IStateManager) LabelStyle).LoadViewState (states [7]);
1365                         if (states [8] != null) ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
1366                         if (states [9] != null) ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
1367                 }
1368
1369                 protected override object SaveViewState ()
1370                 {
1371                         object [] state = new object [10];
1372                         state [0] = base.SaveViewState ();
1373
1374                         if (TextBoxStyle != null) state [1] = ((IStateManager) TextBoxStyle).SaveViewState ();
1375                         if (ValidatorTextStyle != null) state [2] = ((IStateManager) ValidatorTextStyle).SaveViewState ();
1376                         if (CompleteSuccessTextStyle != null) state [3] = ((IStateManager) CompleteSuccessTextStyle).SaveViewState ();
1377                         if (ErrorMessageStyle != null) state [4] = ((IStateManager) ErrorMessageStyle).SaveViewState ();
1378                         if (HyperLinkStyle != null) state [5] = ((IStateManager) HyperLinkStyle).SaveViewState ();
1379                         if (InstructionTextStyle != null) state [6] = ((IStateManager) InstructionTextStyle).SaveViewState ();
1380                         if (LabelStyle != null) state [7] = ((IStateManager) LabelStyle).SaveViewState ();
1381                         if (PasswordHintStyle != null) state [8] = ((IStateManager) PasswordHintStyle).SaveViewState ();
1382                         if (TitleTextStyle != null) state [9] = ((IStateManager) TitleTextStyle).SaveViewState ();
1383
1384                         for (int n = 0; n < state.Length; n++)
1385                                 if (state [n] != null) return state;
1386
1387                         return null;
1388                 }
1389
1390                 [MonoTODO ("for design-time usage - no more details available")]
1391                 protected override void SetDesignModeState (IDictionary data)
1392                 {
1393                         base.SetDesignModeState (data);
1394                 }
1395
1396                 protected override void TrackViewState ()
1397                 {
1398                         base.TrackViewState ();
1399                         if (_textBoxStyle != null) ((IStateManager) _textBoxStyle).TrackViewState ();
1400                         if (_validatorTextStyle != null) ((IStateManager) _validatorTextStyle).TrackViewState ();
1401                         if (_completeSuccessTextStyle != null) ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
1402                         if (_errorMessageStyle != null) ((IStateManager) _errorMessageStyle).TrackViewState ();
1403                         if (_hyperLinkStyle != null) ((IStateManager) _hyperLinkStyle).TrackViewState ();
1404                         if (_instructionTextStyle != null) ((IStateManager) _instructionTextStyle).TrackViewState ();
1405                         if (_labelStyle != null) ((IStateManager) _labelStyle).TrackViewState ();
1406                         if (_passwordHintStyle != null) ((IStateManager) _passwordHintStyle).TrackViewState ();
1407                         if (_titleTextStyle != null) ((IStateManager) _titleTextStyle).TrackViewState ();
1408                 }
1409
1410                 #endregion
1411
1412                 #region Private event handlers
1413
1414                 private void UserName_TextChanged (object sender, EventArgs e)
1415                 {
1416                         UserName = ((ITextControl) sender).Text;
1417                 }
1418
1419                 private void Password_TextChanged (object sender, EventArgs e)
1420                 {
1421                         _password = ((ITextControl) sender).Text;
1422                 }
1423
1424                 private void ConfirmPassword_TextChanged (object sender, EventArgs e)
1425                 {
1426                         _confirmPassword = ((ITextControl) sender).Text;
1427                 }
1428
1429                 private void Email_TextChanged (object sender, EventArgs e)
1430                 {
1431                         Email = ((ITextControl) sender).Text;
1432                 }
1433
1434                 private void Question_TextChanged (object sender, EventArgs e)
1435                 {
1436                         Question = ((ITextControl) sender).Text;
1437                 }
1438
1439                 private void Answer_TextChanged (object sender, EventArgs e)
1440                 {
1441                         Answer = ((ITextControl) sender).Text;
1442                 }
1443
1444                 #endregion
1445
1446                 #region Private Methods
1447
1448                 private void InitMemberShipProvider ()
1449                 {
1450                         string mp = MembershipProvider;
1451                         _provider = (mp.Length == 0) ? _provider = Membership.Provider : Membership.Providers [mp];
1452                         if (_provider == null)
1453                                 throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
1454                 }
1455
1456                 private bool CreateUser ()
1457                 {
1458                         if (!Page.IsValid)
1459                                 return false;
1460
1461                         if (AutoGeneratePassword)
1462                                 _password = GeneratePassword ();
1463
1464                         OnCreatingUser (new LoginCancelEventArgs (false));
1465
1466                         MembershipCreateStatus status;
1467                         MembershipUser newUser = MembershipProviderInternal.CreateUser (
1468                                 UserName, Password, Email, Question, Answer, !DisableCreatedUser, null, out status);
1469
1470                         if ((newUser != null) && (status == MembershipCreateStatus.Success)) {
1471                                 OnCreatedUser (new EventArgs ());
1472                                 return true;
1473                         }
1474
1475                         switch (status) {
1476                                 case MembershipCreateStatus.DuplicateUserName:
1477                                         ShowErrorMessage (DuplicateUserNameErrorMessage);
1478                                         break;
1479
1480                                 case MembershipCreateStatus.InvalidPassword:
1481                                         ShowErrorMessage (String.Format (InvalidPasswordErrorMessage, MembershipProviderInternal.MinRequiredPasswordLength, MembershipProviderInternal.MinRequiredNonAlphanumericCharacters));
1482                                         break;
1483
1484                                 case MembershipCreateStatus.DuplicateEmail:
1485                                         ShowErrorMessage (DuplicateEmailErrorMessage);
1486                                         break;
1487
1488                                 case MembershipCreateStatus.InvalidEmail:
1489                                         ShowErrorMessage (InvalidEmailErrorMessage);
1490                                         break;
1491
1492                                 case MembershipCreateStatus.InvalidQuestion:
1493                                         ShowErrorMessage (InvalidQuestionErrorMessage);
1494                                         break;
1495
1496                                 case MembershipCreateStatus.InvalidAnswer:
1497                                         ShowErrorMessage (InvalidAnswerErrorMessage);
1498                                         break;
1499
1500                                 case MembershipCreateStatus.UserRejected:
1501                                 case MembershipCreateStatus.InvalidUserName:
1502                                 case MembershipCreateStatus.ProviderError:
1503                                 case MembershipCreateStatus.InvalidProviderUserKey:
1504                                         ShowErrorMessage (UnknownErrorMessage);
1505                                         break;
1506
1507
1508                         }
1509
1510                         OnCreateUserError (new CreateUserErrorEventArgs (status));
1511
1512                         return false;
1513                 }
1514
1515                 private void Login ()
1516                 {
1517                         bool userValidated = MembershipProviderInternal.ValidateUser (UserName, Password);
1518                         if (userValidated)
1519                                 FormsAuthentication.SetAuthCookie (UserName, false);
1520                 }
1521
1522                 private void ShowErrorMessage (string errorMessage)
1523                 {
1524                         if (_errorMessageLabel != null)
1525                                 _errorMessageLabel.Text = errorMessage;
1526                 }
1527
1528                 private string GeneratePassword ()
1529                 {
1530                         return Membership.GeneratePassword (8, 3);
1531                 }
1532
1533                 #endregion
1534
1535                 #region SideBarLabelTemplate
1536
1537                 class SideBarLabelTemplate : ITemplate
1538                 {
1539                         Wizard wizard;
1540
1541                         public SideBarLabelTemplate (Wizard wizard)
1542                         {
1543                                 this.wizard = wizard;
1544                         }
1545
1546                         public void InstantiateIn (Control control)
1547                         {
1548                                 Label b = new Label ();
1549                                 wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle, false);
1550                                 control.Controls.Add (b);
1551                                 control.DataBinding += Bound;
1552                         }
1553
1554                         void Bound (object s, EventArgs args)
1555                         {
1556                                 WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
1557                                 if (step != null) {
1558                                         Control c = (Control) s;
1559                                         Label b = (Label) c.Controls [0];
1560                                         b.ID = SideBarButtonID;
1561                                         b.Text = step.Title;
1562                                         if (step == wizard.ActiveStep)
1563                                                 b.Font.Bold = true;
1564                                 }
1565                         }
1566                 }
1567
1568                 #endregion
1569         }
1570 }
1571
1572 #endif