2006-11-28 Miguel de Icaza <miguel@novell.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 { return base.DisplaySideBar; }
377                         set { base.DisplaySideBar = value; }
378                 }
379
380                 [LocalizableAttribute (true)]
381                 public virtual string DuplicateEmailErrorMessage
382                 {
383                         get
384                         {
385                                 object o = ViewState ["DuplicateEmailErrorMessage"];
386                                 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;
387                         }
388                         set
389                         {
390                                 if (value == null)
391                                         ViewState.Remove ("DuplicateEmailErrorMessage");
392                                 else
393                                         ViewState ["DuplicateEmailErrorMessage"] = value;
394                         }
395                 }
396
397                 [LocalizableAttribute (true)]
398                 public virtual string DuplicateUserNameErrorMessage
399                 {
400                         get
401                         {
402                                 object o = ViewState ["DuplicateUserNameErrorMessage"];
403                                 return (o == null) ? Locale.GetText ("Please enter a different user name.") : (string) o;
404                         }
405                         set
406                         {
407                                 if (value == null)
408                                         ViewState.Remove ("DuplicateUserNameErrorMessage");
409                                 else
410                                         ViewState ["DuplicateUserNameErrorMessage"] = value;
411                         }
412                 }
413
414                 public virtual string EditProfileIconUrl
415                 {
416                         get
417                         {
418                                 object o = ViewState ["EditProfileIconUrl"];
419                                 return (o == null) ? "" : (string) o;
420                         }
421                         set
422                         {
423                                 if (value == null)
424                                         ViewState.Remove ("EditProfileIconUrl");
425                                 else
426                                         ViewState ["EditProfileIconUrl"] = value;
427                         }
428                 }
429
430                 [LocalizableAttribute (true)]
431                 public virtual string EditProfileText
432                 {
433                         get
434                         {
435                                 object o = ViewState ["EditProfileText"];
436                                 return (o == null) ? "" : (string) o;
437                         }
438                         set
439                         {
440                                 if (value == null)
441                                         ViewState.Remove ("EditProfileText");
442                                 else
443                                         ViewState ["EditProfileText"] = value;
444                         }
445                 }
446
447                 public virtual string EditProfileUrl
448                 {
449                         get
450                         {
451                                 object o = ViewState ["EditProfileUrl"];
452                                 return (o == null) ? "" : (string) o;
453                         }
454                         set
455                         {
456                                 if (value == null)
457                                         ViewState.Remove ("EditProfileUrl");
458                                 else
459                                         ViewState ["EditProfileUrl"] = value;
460                         }
461                 }
462
463                 public virtual string Email
464                 {
465                         get
466                         {
467                                 object o = ViewState ["Email"];
468                                 return (o == null) ? String.Empty : (string) o;
469                         }
470                         set
471                         {
472                                 if (value == null)
473                                         ViewState.Remove ("Email");
474                                 else
475                                         ViewState ["Email"] = value;
476                         }
477                 }
478
479                 [LocalizableAttribute (true)]
480                 public virtual string EmailLabelText
481                 {
482                         get
483                         {
484                                 object o = ViewState ["EmailLabelText"];
485                                 return (o == null) ? Locale.GetText ("E-mail:") : (string) o;
486                         }
487                         set
488                         {
489                                 if (value == null)
490                                         ViewState.Remove ("EmailLabelText");
491                                 else
492                                         ViewState ["EmailLabelText"] = value;
493                         }
494                 }
495
496                 public virtual string EmailRegularExpression
497                 {
498                         get
499                         {
500                                 object o = ViewState ["EmailRegularExpression"];
501                                 return (o == null) ? "" : (string) o;
502                         }
503                         set
504                         {
505                                 if (value == null)
506                                         ViewState.Remove ("EmailRegularExpression");
507                                 else
508                                         ViewState ["EmailRegularExpression"] = value;
509                         }
510                 }
511
512                 public virtual string EmailRegularExpressionErrorMessage
513                 {
514                         get
515                         {
516                                 object o = ViewState ["EmailRegularExpressionErrorMessage"];
517                                 return (o == null) ? Locale.GetText ("Please enter a different e-mail.") : (string) o;
518                         }
519                         set
520                         {
521                                 if (value == null)
522                                         ViewState.Remove ("EmailRegularExpressionErrorMessage");
523                                 else
524                                         ViewState ["EmailRegularExpressionErrorMessage"] = value;
525                         }
526                 }
527
528                 [LocalizableAttribute (true)]
529                 public virtual string EmailRequiredErrorMessage
530                 {
531                         get
532                         {
533                                 object o = ViewState ["EmailRequiredErrorMessage"];
534                                 return (o == null) ? Locale.GetText ("E-mail is required.") : (string) o;
535                         }
536                         set
537                         {
538                                 if (value == null)
539                                         ViewState.Remove ("EmailRequiredErrorMessage");
540                                 else
541                                         ViewState ["EmailRequiredErrorMessage"] = value;
542                         }
543                 }
544
545                 public TableItemStyle ErrorMessageStyle
546                 {
547                         get
548                         {
549                                 if (_errorMessageStyle == null) {
550                                         _errorMessageStyle = new TableItemStyle ();
551                                         if (IsTrackingViewState)
552                                                 ((IStateManager) _errorMessageStyle).TrackViewState ();
553                                 }
554                                 return _errorMessageStyle;
555                         }
556                 }
557
558                 public virtual string HelpPageIconUrl
559                 {
560                         get
561                         {
562                                 object o = ViewState ["HelpPageIconUrl"];
563                                 return (o == null) ? "" : (string) o;
564                         }
565                         set
566                         {
567                                 if (value == null)
568                                         ViewState.Remove ("HelpPageIconUrl");
569                                 else
570                                         ViewState ["HelpPageIconUrl"] = value;
571                         }
572                 }
573
574                 [LocalizableAttribute (true)]
575                 public virtual string HelpPageText
576                 {
577                         get
578                         {
579                                 object o = ViewState ["HelpPageText"];
580                                 return (o == null) ? "" : (string) o;
581                         }
582                         set
583                         {
584                                 if (value == null)
585                                         ViewState.Remove ("HelpPageText");
586                                 else
587                                         ViewState ["HelpPageText"] = value;
588                         }
589                 }
590
591                 public virtual string HelpPageUrl
592                 {
593                         get
594                         {
595                                 object o = ViewState ["HelpPageUrl"];
596                                 return (o == null) ? "" : (string) o;
597                         }
598                         set
599                         {
600                                 if (value == null)
601                                         ViewState.Remove ("HelpPageUrl");
602                                 else
603                                         ViewState ["HelpPageUrl"] = value;
604                         }
605                 }
606
607                 public TableItemStyle HyperLinkStyle
608                 {
609                         get
610                         {
611                                 if (_hyperLinkStyle == null) {
612                                         _hyperLinkStyle = new TableItemStyle ();
613                                         if (IsTrackingViewState)
614                                                 ((IStateManager) _hyperLinkStyle).TrackViewState ();
615                                 }
616                                 return _hyperLinkStyle;
617                         }
618                 }
619
620                 [LocalizableAttribute (true)]
621                 public virtual string InstructionText
622                 {
623                         get
624                         {
625                                 object o = ViewState ["InstructionText"];
626                                 return (o == null) ? "" : (string) o;
627                         }
628                         set
629                         {
630                                 if (value == null)
631                                         ViewState.Remove ("InstructionText");
632                                 else
633                                         ViewState ["InstructionText"] = value;
634                         }
635                 }
636
637                 public TableItemStyle InstructionTextStyle
638                 {
639                         get
640                         {
641                                 if (_instructionTextStyle == null) {
642                                         _instructionTextStyle = new TableItemStyle ();
643                                         if (IsTrackingViewState)
644                                                 ((IStateManager) _instructionTextStyle).TrackViewState ();
645                                 }
646                                 return _instructionTextStyle;
647                         }
648                 }
649
650                 [LocalizableAttribute (true)]
651                 public virtual string InvalidAnswerErrorMessage
652                 {
653                         get
654                         {
655                                 object o = ViewState ["InvalidAnswerErrorMessage"];
656                                 return (o == null) ? Locale.GetText ("Please enter a different security answer.") : (string) o;
657                         }
658                         set
659                         {
660                                 if (value == null)
661                                         ViewState.Remove ("InvalidAnswerErrorMessage");
662                                 else
663                                         ViewState ["InvalidAnswerErrorMessage"] = value;
664                         }
665                 }
666
667                 [LocalizableAttribute (true)]
668                 public virtual string InvalidEmailErrorMessage
669                 {
670                         get
671                         {
672                                 object o = ViewState ["InvalidEmailErrorMessage"];
673                                 return (o == null) ? Locale.GetText ("Please enter a valid e-mail address.") : (string) o;
674                         }
675                         set
676                         {
677                                 if (value == null)
678                                         ViewState.Remove ("InvalidEmailErrorMessage");
679                                 else
680                                         ViewState ["InvalidEmailErrorMessage"] = value;
681                         }
682                 }
683
684                 [MonoTODO ("take the values from membership provider")]
685                 [LocalizableAttribute (true)]
686                 public virtual string InvalidPasswordErrorMessage
687                 {
688                         get
689                         {
690                                 object o = ViewState ["InvalidPasswordErrorMessage"];
691                                 return (o == null) ? Locale.GetText ("Password length minimum: {0}. Non-alphanumeric characters required: {1}.") : (string) o;
692                         }
693                         set
694                         {
695                                 if (value == null)
696                                         ViewState.Remove ("InvalidPasswordErrorMessage");
697                                 else
698                                         ViewState ["InvalidPasswordErrorMessage"] = value;
699                         }
700                 }
701
702                 [LocalizableAttribute (true)]
703                 public virtual string InvalidQuestionErrorMessage
704                 {
705                         get
706                         {
707                                 object o = ViewState ["InvalidQuestionErrorMessage"];
708                                 return (o == null) ? Locale.GetText ("Please enter a different security question.") : (string) o;
709                         }
710                         set
711                         {
712                                 if (value == null)
713                                         ViewState.Remove ("InvalidQuestionErrorMessage");
714                                 else
715                                         ViewState ["InvalidQuestionErrorMessage"] = value;
716                         }
717                 }
718
719                 public TableItemStyle LabelStyle
720                 {
721                         get
722                         {
723                                 if (_labelStyle == null) {
724                                         _labelStyle = new TableItemStyle ();
725                                         if (IsTrackingViewState)
726                                                 ((IStateManager) _labelStyle).TrackViewState ();
727                                 }
728                                 return _labelStyle;
729                         }
730                 }
731
732                 [ThemeableAttribute (false)]
733                 public virtual bool LoginCreatedUser
734                 {
735                         get
736                         {
737                                 object o = ViewState ["LoginCreatedUser"];
738                                 return (o == null) ? true : (bool) o;
739                         }
740                         set
741                         {
742                                 ViewState ["LoginCreatedUser"] = value;
743                         }
744                 }
745
746                 //[MonoTODO ("Sending mail functionality is not implemented")]
747                 //[ThemeableAttribute (false)]
748                 //public MailDefinition MailDefinition
749                 //{
750                 //      get { throw new NotImplementedException (); }
751                 //}
752
753                 [ThemeableAttribute (false)]
754                 public virtual string MembershipProvider
755                 {
756                         get
757                         {
758                                 object o = ViewState ["MembershipProvider"];
759                                 return (o == null) ? "" : (string) o;
760                         }
761                         set
762                         {
763                                 if (value == null)
764                                         ViewState.Remove ("MembershipProvider");
765                                 else
766                                         ViewState ["MembershipProvider"] = value;
767
768                                 _provider = null;
769                         }
770                 }
771
772                 internal virtual MembershipProvider MembershipProviderInternal
773                 {
774                         get
775                         {
776                                 if (_provider == null)
777                                         InitMemberShipProvider ();
778
779                                 return _provider;
780                         }
781                 }
782
783                 public virtual string Password
784                 {
785                         get { return _password; }
786                 }
787
788                 public TableItemStyle PasswordHintStyle
789                 {
790                         get
791                         {
792                                 if (_passwordHintStyle == null) {
793                                         _passwordHintStyle = new TableItemStyle ();
794                                         if (IsTrackingViewState)
795                                                 ((IStateManager) _passwordHintStyle).TrackViewState ();
796                                 }
797                                 return _passwordHintStyle;
798                         }
799                 }
800
801                 [LocalizableAttribute (true)]
802                 public virtual string PasswordHintText
803                 {
804                         get
805                         {
806                                 object o = ViewState ["PasswordHintText"];
807                                 return (o == null) ? "" : (string) o;
808                         }
809                         set
810                         {
811                                 if (value == null)
812                                         ViewState.Remove ("PasswordHintText");
813                                 else
814                                         ViewState ["PasswordHintText"] = value;
815                         }
816                 }
817
818                 [LocalizableAttribute (true)]
819                 public virtual string PasswordLabelText
820                 {
821                         get
822                         {
823                                 object o = ViewState ["PasswordLabelText"];
824                                 return (o == null) ? Locale.GetText ("Password:") : (string) o;
825                         }
826                         set
827                         {
828                                 if (value == null)
829                                         ViewState.Remove ("PasswordLabelText");
830                                 else
831                                         ViewState ["PasswordLabelText"] = value;
832                         }
833                 }
834
835                 public virtual string PasswordRegularExpression
836                 {
837                         get
838                         {
839                                 object o = ViewState ["PasswordRegularExpression"];
840                                 return (o == null) ? "" : (string) o;
841                         }
842                         set
843                         {
844                                 if (value == null)
845                                         ViewState.Remove ("PasswordRegularExpression");
846                                 else
847                                         ViewState ["PasswordRegularExpression"] = value;
848                         }
849                 }
850
851                 public virtual string PasswordRegularExpressionErrorMessage
852                 {
853                         get
854                         {
855                                 object o = ViewState ["PasswordRegularExpressionErrorMessage"];
856                                 return (o == null) ? Locale.GetText ("Please enter a different password.") : (string) o;
857                         }
858                         set
859                         {
860                                 if (value == null)
861                                         ViewState.Remove ("PasswordRegularExpressionErrorMessage");
862                                 else
863                                         ViewState ["PasswordRegularExpressionErrorMessage"] = value;
864                         }
865                 }
866
867                 [LocalizableAttribute (true)]
868                 public virtual string PasswordRequiredErrorMessage
869                 {
870                         get
871                         {
872                                 object o = ViewState ["PasswordRequiredErrorMessage"];
873                                 return (o == null) ? Locale.GetText ("Password is required.") : (string) o;
874                         }
875                         set
876                         {
877                                 if (value == null)
878                                         ViewState.Remove ("PasswordRequiredErrorMessage");
879                                 else
880                                         ViewState ["PasswordRequiredErrorMessage"] = value;
881                         }
882                 }
883
884                 [LocalizableAttribute (true)]
885                 [ThemeableAttribute (false)]
886                 public virtual string Question
887                 {
888                         get
889                         {
890                                 object o = ViewState ["Question"];
891                                 return (o == null) ? String.Empty : (string) o;
892                         }
893                         set
894                         {
895                                 if (value == null)
896                                         ViewState.Remove ("Question");
897                                 else
898                                         ViewState ["Question"] = value;
899                         }
900                 }
901
902                 [LocalizableAttribute (true)]
903                 public virtual string QuestionLabelText
904                 {
905                         get
906                         {
907                                 object o = ViewState ["QuestionLabelText"];
908                                 return (o == null) ? Locale.GetText ("Security Question:") : (string) o;
909                         }
910                         set
911                         {
912                                 if (value == null)
913                                         ViewState.Remove ("QuestionLabelText");
914                                 else
915                                         ViewState ["QuestionLabelText"] = value;
916                         }
917                 }
918
919                 [LocalizableAttribute (true)]
920                 public virtual string QuestionRequiredErrorMessage
921                 {
922                         get
923                         {
924                                 object o = ViewState ["QuestionRequiredErrorMessage"];
925                                 return (o == null) ? Locale.GetText ("Security question is required.") : (string) o;
926                         }
927                         set
928                         {
929                                 if (value == null)
930                                         ViewState.Remove ("QuestionRequiredErrorMessage");
931                                 else
932                                         ViewState ["QuestionRequiredErrorMessage"] = value;
933                         }
934                 }
935
936                 [ThemeableAttribute (false)]
937                 public virtual bool RequireEmail
938                 {
939                         get
940                         {
941                                 object o = ViewState ["RequireEmail"];
942                                 return (o == null) ? true : (bool) o;
943                         }
944                         set
945                         {
946                                 ViewState ["RequireEmail"] = value;
947                         }
948                 }
949
950                 [MonoTODO ("doesnt work")]
951                 public override string SkipLinkText
952                 {
953                         get
954                         {
955                                 object o = ViewState ["SkipLinkText"];
956                                 return (o == null) ? "" : (string) o;
957                         }
958                         set
959                         {
960                                 if (value == null)
961                                         ViewState.Remove ("SkipLinkText");
962                                 else
963                                         ViewState ["SkipLinkText"] = value;
964                         }
965                 }
966
967                 public Style TextBoxStyle
968                 {
969                         get
970                         {
971                                 if (_textBoxStyle == null) {
972                                         _textBoxStyle = new Style ();
973                                         if (IsTrackingViewState)
974                                                 ((IStateManager) _textBoxStyle).TrackViewState ();
975                                 }
976                                 return _textBoxStyle;
977                         }
978                 }
979
980                 public TableItemStyle TitleTextStyle
981                 {
982                         get
983                         {
984                                 if (_titleTextStyle == null) {
985                                         _titleTextStyle = new TableItemStyle ();
986                                         if (IsTrackingViewState)
987                                                 ((IStateManager) _titleTextStyle).TrackViewState ();
988                                 }
989                                 return _titleTextStyle;
990                         }
991                 }
992
993                 [LocalizableAttribute (true)]
994                 public virtual string UnknownErrorMessage
995                 {
996                         get
997                         {
998                                 object o = ViewState ["UnknownErrorMessage"];
999                                 return (o == null) ? Locale.GetText ("Your account was not created. Please try again.") : (string) o;
1000                         }
1001                         set
1002                         {
1003                                 if (value == null)
1004                                         ViewState.Remove ("UnknownErrorMessage");
1005                                 else
1006                                         ViewState ["UnknownErrorMessage"] = value;
1007                         }
1008                 }
1009
1010                 public virtual string UserName
1011                 {
1012                         get
1013                         {
1014                                 object o = ViewState ["UserName"];
1015                                 return (o == null) ? String.Empty : (string) o;
1016                         }
1017                         set
1018                         {
1019                                 if (value == null)
1020                                         ViewState.Remove ("UserName");
1021                                 else
1022                                         ViewState ["UserName"] = value;
1023                         }
1024                 }
1025
1026                 [LocalizableAttribute (true)]
1027                 public virtual string UserNameLabelText
1028                 {
1029                         get
1030                         {
1031                                 object o = ViewState ["UserNameLabelText"];
1032                                 return (o == null) ? Locale.GetText ("User Name:") : (string) o;
1033                         }
1034                         set
1035                         {
1036                                 if (value == null)
1037                                         ViewState.Remove ("UserNameLabelText");
1038                                 else
1039                                         ViewState ["UserNameLabelText"] = value;
1040                         }
1041                 }
1042
1043                 [LocalizableAttribute (true)]
1044                 public virtual string UserNameRequiredErrorMessage
1045                 {
1046                         get
1047                         {
1048                                 object o = ViewState ["UserNameRequiredErrorMessage"];
1049                                 return (o == null) ? Locale.GetText ("User Name is required.") : (string) o;
1050                         }
1051                         set
1052                         {
1053                                 if (value == null)
1054                                         ViewState.Remove ("UserNameRequiredErrorMessage");
1055                                 else
1056                                         ViewState ["UserNameRequiredErrorMessage"] = value;
1057                         }
1058                 }
1059
1060                 public Style ValidatorTextStyle
1061                 {
1062                         get
1063                         {
1064                                 if (_validatorTextStyle == null) {
1065                                         _validatorTextStyle = new Style ();
1066                                         if (IsTrackingViewState)
1067                                                 ((IStateManager) _validatorTextStyle).TrackViewState ();
1068                                 }
1069                                 return _validatorTextStyle;
1070                         }
1071                 }
1072
1073                 [ThemeableAttribute (false)]
1074                 public override WizardStepCollection WizardSteps
1075                 {
1076                         get { return base.WizardSteps; }
1077                 }
1078
1079                 #endregion
1080
1081                 #region Protected Properties
1082
1083                 protected internal bool QuestionAndAnswerRequired
1084                 {
1085                         get { return MembershipProviderInternal.RequiresQuestionAndAnswer; }
1086                 }
1087
1088                 public event EventHandler ContinueButtonClick
1089                 {
1090                         add { Events.AddHandler (ContinueButtonClickEvent, value); }
1091                         remove { Events.RemoveHandler (ContinueButtonClickEvent, value); }
1092                 }
1093
1094                 public event EventHandler CreatedUser
1095                 {
1096                         add { Events.AddHandler (CreatedUserEvent, value); }
1097                         remove { Events.RemoveHandler (CreatedUserEvent, value); }
1098                 }
1099
1100                 public event CreateUserErrorEventHandler CreateUserError
1101                 {
1102                         add { Events.AddHandler (CreateUserErrorEvent, value); }
1103                         remove { Events.RemoveHandler (CreateUserErrorEvent, value); }
1104                 }
1105
1106                 public event LoginCancelEventHandler CreatingUser
1107                 {
1108                         add { Events.AddHandler (CreatingUserEvent, value); }
1109                         remove { Events.RemoveHandler (CreatingUserEvent, value); }
1110                 }
1111
1112                 public event MailMessageEventHandler SendingMail
1113                 {
1114                         add { Events.AddHandler (SendingMailEvent, value); }
1115                         remove { Events.RemoveHandler (SendingMailEvent, value); }
1116                 }
1117
1118                 public event SendMailErrorEventHandler SendMailError
1119                 {
1120                         add { Events.AddHandler (SendMailErrorEvent, value); }
1121                         remove { Events.RemoveHandler (SendMailErrorEvent, value); }
1122                 }
1123
1124
1125                 #endregion
1126
1127                 #region Internal Properties
1128
1129                 internal override void InstantiateTemplateStep (TemplatedWizardStep step)
1130                 {
1131                         base.InstantiateTemplateStep (step);
1132                 }
1133
1134                 internal override ITemplate SideBarItemTemplate
1135                 {
1136                         get { return new SideBarLabelTemplate (this); }
1137                 }
1138
1139                 #endregion
1140
1141                 #region Protected Methods
1142
1143                 protected internal override void CreateChildControls ()
1144                 {
1145                         base.FinishCompleteButtonText = ContinueButtonText;
1146                         base.StartNextButtonText = CreateUserButtonText;
1147
1148                         CreateUserWizardStep c = CreateUserStep;
1149
1150                         base.CreateChildControls ();
1151                 }
1152
1153                 protected override void CreateControlHierarchy ()
1154                 {
1155                         base.CreateControlHierarchy ();
1156
1157                         CreateUserStepContainer container = CreateUserStep.ContentTemplateContainer as CreateUserStepContainer;
1158
1159                         if (container != null) {
1160                                 IEditableTextControl editable;
1161                                 editable = container.UserNameTextBox as IEditableTextControl;
1162
1163                                 if (editable != null)
1164                                         editable.TextChanged += new EventHandler (UserName_TextChanged);
1165
1166                                 if (!AutoGeneratePassword) {
1167                                         editable = container.PasswordTextBox as IEditableTextControl;
1168
1169                                         if (editable != null)
1170                                                 editable.TextChanged += new EventHandler (Password_TextChanged);
1171
1172                                         editable = container.ConfirmPasswordTextBox as IEditableTextControl;
1173
1174                                         if (editable != null)
1175                                                 editable.TextChanged += new EventHandler (ConfirmPassword_TextChanged);
1176                                 }
1177
1178                                 if (RequireEmail) {
1179                                         editable = container.EmailTextBox as IEditableTextControl;
1180
1181                                         if (editable != null)
1182                                                 editable.TextChanged += new EventHandler (Email_TextChanged);
1183                                 }
1184
1185                                 if (QuestionAndAnswerRequired) {
1186                                         editable = container.QuestionTextBox as IEditableTextControl;
1187
1188                                         if (editable != null)
1189                                                 editable.TextChanged += new EventHandler (Question_TextChanged);
1190
1191                                         editable = container.AnswerTextBox as IEditableTextControl;
1192
1193                                         if (editable != null)
1194                                                 editable.TextChanged += new EventHandler (Answer_TextChanged);
1195                                 }
1196
1197                                 _errorMessageLabel = container.ErrorMessageLabel;
1198                         }
1199                 }
1200
1201                 [MonoTODO ("Not Implemented")]
1202                 protected override IDictionary GetDesignModeState ()
1203                 {
1204                         throw new NotImplementedException ();
1205                 }
1206
1207                 protected internal override void OnInit (EventArgs e)
1208                 {
1209                         base.OnInit (e);
1210
1211                         DisplaySideBar = false;
1212
1213                         if (CreateUserStep == null)
1214                                 WizardSteps.AddAt (0, new CreateUserWizardStep ());
1215
1216                         if (CompleteStep == null)
1217                                 WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
1218
1219                         if (ActiveStepIndex < 0)
1220                                 ActiveStepIndex = 0;
1221                 }
1222
1223                 protected override bool OnBubbleEvent (object source, EventArgs e)
1224                 {
1225                         CommandEventArgs args = e as CommandEventArgs;
1226                         if (e != null && args.CommandName == ContinueButtonCommandName) {
1227                                 ProcessContinueEvent ();
1228                                 return true;
1229                         }
1230                         return base.OnBubbleEvent (source, e);
1231                 }
1232
1233                 private void ProcessContinueEvent () {
1234                         OnContinueButtonClick (EventArgs.Empty);
1235
1236                         if (ContinueDestinationPageUrl.Length > 0) {
1237                                 Context.Response.Redirect (ContinueDestinationPageUrl);
1238                         }
1239                 }
1240
1241                 protected virtual void OnContinueButtonClick (EventArgs e)
1242                 {
1243                         if (Events != null) {
1244                                 EventHandler eh = (EventHandler) Events [ContinueButtonClickEvent];
1245                                 if (eh != null) eh (this, e);
1246                         }
1247                 }
1248
1249                 protected virtual void OnCreatedUser (EventArgs e)
1250                 {
1251                         if (Events != null) {
1252                                 EventHandler eh = (EventHandler) Events [CreatedUserEvent];
1253                                 if (eh != null) eh (this, e);
1254                         }
1255                 }
1256
1257                 protected virtual void OnCreateUserError (CreateUserErrorEventArgs e)
1258                 {
1259                         if (Events != null) {
1260                                 CreateUserErrorEventHandler eh = (CreateUserErrorEventHandler) Events [CreateUserErrorEvent];
1261                                 if (eh != null) eh (this, e);
1262                         }
1263                 }
1264
1265                 protected virtual void OnCreatingUser (LoginCancelEventArgs e)
1266                 {
1267                         if (Events != null) {
1268                                 LoginCancelEventHandler eh = (LoginCancelEventHandler) Events [CreatingUserEvent];
1269                                 if (eh != null) eh (this, e);
1270                         }
1271                 }
1272
1273                 protected override void OnNextButtonClick (WizardNavigationEventArgs e)
1274                 {
1275                         bool userCreated = CreateUser ();
1276                         if (!userCreated)
1277                                 e.Cancel = true;
1278                         else
1279                                 if (LoginCreatedUser)
1280                                         Login ();
1281
1282                         base.OnNextButtonClick (e);
1283                 }
1284
1285                 protected internal override void OnPreRender (EventArgs e)
1286                 {
1287                         base.OnPreRender (e);
1288                 }
1289
1290                 protected virtual void OnSendingMail (MailMessageEventArgs e)
1291                 {
1292                         if (Events != null) {
1293                                 MailMessageEventHandler eh = (MailMessageEventHandler) Events [SendingMailEvent];
1294                                 if (eh != null) eh (this, e);
1295                         }
1296                 }
1297
1298                 protected virtual void OnSendMailError (SendMailErrorEventArgs e)
1299                 {
1300                         if (Events != null) {
1301                                 SendMailErrorEventHandler eh = (SendMailErrorEventHandler) Events [SendMailErrorEvent];
1302                                 if (eh != null) eh (this, e);
1303                         }
1304                 }
1305
1306                 protected override void LoadViewState (object savedState)
1307                 {
1308                         if (savedState == null) {
1309                                 base.LoadViewState (null);
1310                                 return;
1311                         }
1312
1313                         object [] states = (object []) savedState;
1314                         base.LoadViewState (states [0]);
1315
1316                         if (states [1] != null) ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
1317                         if (states [2] != null) ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
1318                         if (states [3] != null) ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
1319                         if (states [4] != null) ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
1320                         if (states [5] != null) ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
1321                         if (states [6] != null) ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
1322                         if (states [7] != null) ((IStateManager) LabelStyle).LoadViewState (states [7]);
1323                         if (states [8] != null) ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
1324                         if (states [9] != null) ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
1325                 }
1326
1327                 protected override object SaveViewState ()
1328                 {
1329                         object [] state = new object [10];
1330                         state [0] = base.SaveViewState ();
1331
1332                         if (TextBoxStyle != null) state [1] = ((IStateManager) TextBoxStyle).SaveViewState ();
1333                         if (ValidatorTextStyle != null) state [2] = ((IStateManager) ValidatorTextStyle).SaveViewState ();
1334                         if (CompleteSuccessTextStyle != null) state [3] = ((IStateManager) CompleteSuccessTextStyle).SaveViewState ();
1335                         if (ErrorMessageStyle != null) state [4] = ((IStateManager) ErrorMessageStyle).SaveViewState ();
1336                         if (HyperLinkStyle != null) state [5] = ((IStateManager) HyperLinkStyle).SaveViewState ();
1337                         if (InstructionTextStyle != null) state [6] = ((IStateManager) InstructionTextStyle).SaveViewState ();
1338                         if (LabelStyle != null) state [7] = ((IStateManager) LabelStyle).SaveViewState ();
1339                         if (PasswordHintStyle != null) state [8] = ((IStateManager) PasswordHintStyle).SaveViewState ();
1340                         if (TitleTextStyle != null) state [9] = ((IStateManager) TitleTextStyle).SaveViewState ();
1341
1342                         for (int n = 0; n < state.Length; n++)
1343                                 if (state [n] != null) return state;
1344
1345                         return null;
1346                 }
1347
1348                 [MonoTODO ("for design-time usage - no more details available")]
1349                 protected override void SetDesignModeState (IDictionary data)
1350                 {
1351                         base.SetDesignModeState (data);
1352                 }
1353
1354                 protected override void TrackViewState ()
1355                 {
1356                         base.TrackViewState ();
1357                         if (_textBoxStyle != null) ((IStateManager) _textBoxStyle).TrackViewState ();
1358                         if (_validatorTextStyle != null) ((IStateManager) _validatorTextStyle).TrackViewState ();
1359                         if (_completeSuccessTextStyle != null) ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
1360                         if (_errorMessageStyle != null) ((IStateManager) _errorMessageStyle).TrackViewState ();
1361                         if (_hyperLinkStyle != null) ((IStateManager) _hyperLinkStyle).TrackViewState ();
1362                         if (_instructionTextStyle != null) ((IStateManager) _instructionTextStyle).TrackViewState ();
1363                         if (_labelStyle != null) ((IStateManager) _labelStyle).TrackViewState ();
1364                         if (_passwordHintStyle != null) ((IStateManager) _passwordHintStyle).TrackViewState ();
1365                         if (_titleTextStyle != null) ((IStateManager) _titleTextStyle).TrackViewState ();
1366                 }
1367
1368                 #endregion
1369
1370                 #region Private event handlers
1371
1372                 private void UserName_TextChanged (object sender, EventArgs e)
1373                 {
1374                         UserName = ((ITextControl) sender).Text;
1375                 }
1376
1377                 private void Password_TextChanged (object sender, EventArgs e)
1378                 {
1379                         _password = ((ITextControl) sender).Text;
1380                 }
1381
1382                 private void ConfirmPassword_TextChanged (object sender, EventArgs e)
1383                 {
1384                         _confirmPassword = ((ITextControl) sender).Text;
1385                 }
1386
1387                 private void Email_TextChanged (object sender, EventArgs e)
1388                 {
1389                         Email = ((ITextControl) sender).Text;
1390                 }
1391
1392                 private void Question_TextChanged (object sender, EventArgs e)
1393                 {
1394                         Question = ((ITextControl) sender).Text;
1395                 }
1396
1397                 private void Answer_TextChanged (object sender, EventArgs e)
1398                 {
1399                         Answer = ((ITextControl) sender).Text;
1400                 }
1401
1402                 #endregion
1403
1404                 #region Private Methods
1405
1406                 private void InitMemberShipProvider ()
1407                 {
1408                         string mp = MembershipProvider;
1409                         _provider = (mp.Length == 0) ? _provider = Membership.Provider : Membership.Providers [mp];
1410                         if (_provider == null)
1411                                 throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
1412                 }
1413
1414                 private bool CreateUser ()
1415                 {
1416                         if (!Page.IsValid)
1417                                 return false;
1418
1419                         if (AutoGeneratePassword)
1420                                 _password = GeneratePassword ();
1421
1422                         OnCreatingUser (new LoginCancelEventArgs (false));
1423
1424                         MembershipCreateStatus status;
1425                         MembershipUser newUser = MembershipProviderInternal.CreateUser (
1426                                 UserName, Password, Email, Question, Answer, !DisableCreatedUser, null, out status);
1427
1428                         if ((newUser != null) && (status == MembershipCreateStatus.Success)) {
1429                                 OnCreatedUser (new EventArgs ());
1430                                 return true;
1431                         }
1432
1433                         switch (status) {
1434                                 case MembershipCreateStatus.DuplicateUserName:
1435                                         ShowErrorMessage (DuplicateUserNameErrorMessage);
1436                                         break;
1437
1438                                 case MembershipCreateStatus.InvalidPassword:
1439                                         ShowErrorMessage (String.Format (InvalidPasswordErrorMessage, MembershipProviderInternal.MinRequiredPasswordLength, MembershipProviderInternal.MinRequiredNonAlphanumericCharacters));
1440                                         break;
1441
1442                                 case MembershipCreateStatus.DuplicateEmail:
1443                                         ShowErrorMessage (DuplicateEmailErrorMessage);
1444                                         break;
1445
1446                                 case MembershipCreateStatus.InvalidEmail:
1447                                         ShowErrorMessage (InvalidEmailErrorMessage);
1448                                         break;
1449
1450                                 case MembershipCreateStatus.InvalidQuestion:
1451                                         ShowErrorMessage (InvalidQuestionErrorMessage);
1452                                         break;
1453
1454                                 case MembershipCreateStatus.InvalidAnswer:
1455                                         ShowErrorMessage (InvalidAnswerErrorMessage);
1456                                         break;
1457
1458                                 case MembershipCreateStatus.UserRejected:
1459                                 case MembershipCreateStatus.InvalidUserName:
1460                                 case MembershipCreateStatus.ProviderError:
1461                                 case MembershipCreateStatus.InvalidProviderUserKey:
1462                                         ShowErrorMessage (UnknownErrorMessage);
1463                                         break;
1464
1465
1466                         }
1467
1468                         OnCreateUserError (new CreateUserErrorEventArgs (status));
1469
1470                         return false;
1471                 }
1472
1473                 private void Login ()
1474                 {
1475                         bool userValidated = MembershipProviderInternal.ValidateUser (UserName, Password);
1476                         if (userValidated)
1477                                 FormsAuthentication.SetAuthCookie (UserName, false);
1478                 }
1479
1480                 private void ShowErrorMessage (string errorMessage)
1481                 {
1482                         if (_errorMessageLabel != null)
1483                                 _errorMessageLabel.Text = errorMessage;
1484                 }
1485
1486                 private string GeneratePassword ()
1487                 {
1488                         // FIXME:
1489                         // Generate an actual password!
1490                         
1491                         return "password";
1492                 }
1493
1494                 #endregion
1495
1496                 #region SideBarLabelTemplate
1497
1498                 class SideBarLabelTemplate : ITemplate
1499                 {
1500                         Wizard wizard;
1501
1502                         public SideBarLabelTemplate (Wizard wizard)
1503                         {
1504                                 this.wizard = wizard;
1505                         }
1506
1507                         public void InstantiateIn (Control control)
1508                         {
1509                                 Label b = new Label ();
1510                                 wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
1511                                 control.Controls.Add (b);
1512                                 control.DataBinding += Bound;
1513                         }
1514
1515                         void Bound (object s, EventArgs args)
1516                         {
1517                                 WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
1518                                 if (step != null) {
1519                                         Control c = (Control) s;
1520                                         Label b = (Label) c.Controls [0];
1521                                         b.ID = SideBarButtonID;
1522                                         b.Text = step.Title;
1523                                         if (step == wizard.ActiveStep)
1524                                                 b.Font.Bold = true;
1525                                 }
1526                         }
1527                 }
1528
1529                 #endregion
1530         }
1531 }
1532
1533 #endif