| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347 |
- //
- // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
- //
- // Authors:
- // Vladimir Krasnov <[email protected]>
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- #if NET_2_0
- using System;
- using System.Web;
- using System.Web.UI;
- using System.Web.Security;
- using System.Collections;
- using System.Collections.Specialized;
- using System.ComponentModel;
- using System.Text;
- using System.Net.Mail;
- namespace System.Web.UI.WebControls
- {
- [BindableAttribute (false)]
- public class CreateUserWizard : Wizard
- {
- public static readonly string ContinueButtonCommandName = "Continue";
- private string _password = "";
- private string _confirmPassword = "";
- private MembershipProvider _provider = null;
- private ITextControl _errorMessageLabel = null;
- private MailDefinition _mailDefinition = null;
- private Style _textBoxStyle = null;
- private Style _validatorTextStyle = null;
- private TableItemStyle _completeSuccessTextStyle = null;
- private TableItemStyle _errorMessageStyle = null;
- private TableItemStyle _hyperLinkStyle = null;
- private TableItemStyle _instructionTextStyle = null;
- private TableItemStyle _labelStyle = null;
- private TableItemStyle _passwordHintStyle = null;
- private TableItemStyle _titleTextStyle = null;
- Style _createUserButtonStyle;
- Style _continueButtonStyle;
- private static readonly object CreatedUserEvent = new object ();
- private static readonly object CreateUserErrorEvent = new object ();
- private static readonly object CreatingUserEvent = new object ();
- private static readonly object ContinueButtonClickEvent = new object ();
- private static readonly object SendingMailEvent = new object ();
- private static readonly object SendMailErrorEvent = new object ();
- private CompleteWizardStep _completeWizardStep = null;
- private CreateUserWizardStep _createUserWizardStep = null;
- public CreateUserWizard ()
- {
- }
- #region Public Properties
- public override int ActiveStepIndex
- {
- get { return base.ActiveStepIndex; }
- set { base.ActiveStepIndex = value; }
- }
- [LocalizableAttribute (true)]
- [ThemeableAttribute (false)]
- public virtual string Answer
- {
- get
- {
- object o = ViewState ["Answer"];
- return (o == null) ? String.Empty : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("Answer");
- else
- ViewState ["Answer"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string AnswerLabelText
- {
- get
- {
- object o = ViewState ["AnswerLabelText"];
- return (o == null) ? Locale.GetText ("Security Answer:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("AnswerLabelText");
- else
- ViewState ["AnswerLabelText"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string AnswerRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["AnswerRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("Security answer is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("AnswerRequiredErrorMessage");
- else
- ViewState ["AnswerRequiredErrorMessage"] = value;
- }
- }
- [ThemeableAttribute (false)]
- public virtual bool AutoGeneratePassword
- {
- get
- {
- object o = ViewState ["AutoGeneratePassword"];
- return (o == null) ? false : (bool) o;
- }
- set
- {
- ViewState ["AutoGeneratePassword"] = value;
- }
- }
- public CompleteWizardStep CompleteStep
- {
- get
- {
- if (_completeWizardStep == null) {
- for (int i = 0; i < WizardSteps.Count; i++)
- if (WizardSteps [i] is CompleteWizardStep) {
- _completeWizardStep = (CompleteWizardStep) WizardSteps [i];
- if (_completeWizardStep.Wizard == null)
- _completeWizardStep.SetWizard (this);
- }
- }
- return _completeWizardStep;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string CompleteSuccessText
- {
- get
- {
- object o = ViewState ["CompleteSuccessText"];
- return (o == null) ? Locale.GetText ("Your account has been successfully created.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("CompleteSuccessText");
- else
- ViewState ["CompleteSuccessText"] = value;
- }
- }
- public TableItemStyle CompleteSuccessTextStyle
- {
- get
- {
- if (_completeSuccessTextStyle == null) {
- _completeSuccessTextStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
- }
- return _completeSuccessTextStyle;
- }
- }
- public virtual string ConfirmPassword
- {
- get { return _confirmPassword; }
- }
- [LocalizableAttribute (true)]
- public virtual string ConfirmPasswordCompareErrorMessage
- {
- get
- {
- object o = ViewState ["ConfirmPasswordCompareErrorMessage"];
- return (o == null) ? Locale.GetText ("The Password and Confirmation Password must match.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("ConfirmPasswordCompareErrorMessage");
- else
- ViewState ["ConfirmPasswordCompareErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string ConfirmPasswordLabelText
- {
- get
- {
- object o = ViewState ["ConfirmPasswordLabelText"];
- return (o == null) ? Locale.GetText ("Confirm Password:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("ConfirmPasswordLabelText");
- else
- ViewState ["ConfirmPasswordLabelText"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string ConfirmPasswordRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["ConfirmPasswordRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("Confirm Password is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("ConfirmPasswordRequiredErrorMessage");
- else
- ViewState ["ConfirmPasswordRequiredErrorMessage"] = value;
- }
- }
- public virtual string ContinueButtonImageUrl
- {
- get { return ViewState.GetString ("ContinueButtonImageUrl", String.Empty); }
- set { ViewState ["ContinueButtonImageUrl"] = value; }
- }
- public Style ContinueButtonStyle
- {
- get {
- if (_continueButtonStyle == null) {
- _continueButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager) _continueButtonStyle).TrackViewState ();
- }
- return _continueButtonStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string ContinueButtonText
- {
- get { return ViewState.GetString ("ContinueButtonText", "Continue"); }
- set { ViewState ["ContinueButtonText"] = value; }
- }
- public virtual ButtonType ContinueButtonType
- {
- get {
- object v = ViewState ["ContinueButtonType"];
- return v != null ? (ButtonType) v : ButtonType.Button;
- }
- set {
- ViewState ["ContinueButtonType"] = value;
- }
- }
- [ThemeableAttribute (false)]
- public virtual string ContinueDestinationPageUrl
- {
- get
- {
- object o = ViewState ["ContinueDestinationPageUrl"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("ContinueDestinationPageUrl");
- else
- ViewState ["ContinueDestinationPageUrl"] = value;
- }
- }
- public virtual string CreateUserButtonImageUrl
- {
- get { return ViewState.GetString ("CreateUserButtonImageUrl", String.Empty); }
- set { ViewState ["CreateUserButtonImageUrl"] = value; }
- }
- public Style CreateUserButtonStyle
- {
- get {
- if (_createUserButtonStyle == null) {
- _createUserButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager) _createUserButtonStyle).TrackViewState ();
- }
- return _createUserButtonStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string CreateUserButtonText
- {
- get { return ViewState.GetString ("CreateUserButtonText", "Create User"); }
- set { ViewState ["CreateUserButtonText"] = value; }
- }
- public virtual ButtonType CreateUserButtonType
- {
- get {
- object v = ViewState ["CreateUserButtonType"];
- return v != null ? (ButtonType) v : ButtonType.Button;
- }
- set {
- ViewState ["CreateUserButtonType"] = value;
- }
- }
- public CreateUserWizardStep CreateUserStep
- {
- get
- {
- if (_createUserWizardStep == null) {
- for (int i = 0; i < WizardSteps.Count; i++)
- if (WizardSteps [i] is CreateUserWizardStep) {
- _createUserWizardStep = (CreateUserWizardStep) WizardSteps [i];
- if (_createUserWizardStep.Wizard == null)
- _createUserWizardStep.SetWizard (this);
- }
- }
- return _createUserWizardStep;
- }
- }
- [ThemeableAttribute (false)]
- public virtual bool DisableCreatedUser
- {
- get
- {
- object o = ViewState ["DisableCreatedUser"];
- return (o == null) ? false : (bool) o;
- }
- set
- {
- ViewState ["DisableCreatedUser"] = value;
- }
- }
- public override bool DisplaySideBar
- {
- get {
- return ViewState.GetBool ("DisplaySideBar", false);
- }
- set {
- ViewState ["DisplaySideBar"] = value;
- ChildControlsCreated = false;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string DuplicateEmailErrorMessage
- {
- get
- {
- object o = ViewState ["DuplicateEmailErrorMessage"];
- 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;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("DuplicateEmailErrorMessage");
- else
- ViewState ["DuplicateEmailErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string DuplicateUserNameErrorMessage
- {
- get
- {
- object o = ViewState ["DuplicateUserNameErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a different user name.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("DuplicateUserNameErrorMessage");
- else
- ViewState ["DuplicateUserNameErrorMessage"] = value;
- }
- }
- public virtual string EditProfileIconUrl
- {
- get
- {
- object o = ViewState ["EditProfileIconUrl"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EditProfileIconUrl");
- else
- ViewState ["EditProfileIconUrl"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string EditProfileText
- {
- get
- {
- object o = ViewState ["EditProfileText"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EditProfileText");
- else
- ViewState ["EditProfileText"] = value;
- }
- }
- public virtual string EditProfileUrl
- {
- get
- {
- object o = ViewState ["EditProfileUrl"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EditProfileUrl");
- else
- ViewState ["EditProfileUrl"] = value;
- }
- }
- public virtual string Email
- {
- get
- {
- object o = ViewState ["Email"];
- return (o == null) ? String.Empty : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("Email");
- else
- ViewState ["Email"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string EmailLabelText
- {
- get
- {
- object o = ViewState ["EmailLabelText"];
- return (o == null) ? Locale.GetText ("E-mail:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EmailLabelText");
- else
- ViewState ["EmailLabelText"] = value;
- }
- }
- public virtual string EmailRegularExpression
- {
- get
- {
- object o = ViewState ["EmailRegularExpression"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EmailRegularExpression");
- else
- ViewState ["EmailRegularExpression"] = value;
- }
- }
- public virtual string EmailRegularExpressionErrorMessage
- {
- get
- {
- object o = ViewState ["EmailRegularExpressionErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a different e-mail.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EmailRegularExpressionErrorMessage");
- else
- ViewState ["EmailRegularExpressionErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string EmailRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["EmailRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("E-mail is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("EmailRequiredErrorMessage");
- else
- ViewState ["EmailRequiredErrorMessage"] = value;
- }
- }
- public TableItemStyle ErrorMessageStyle
- {
- get
- {
- if (_errorMessageStyle == null) {
- _errorMessageStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _errorMessageStyle).TrackViewState ();
- }
- return _errorMessageStyle;
- }
- }
- public virtual string HelpPageIconUrl
- {
- get
- {
- object o = ViewState ["HelpPageIconUrl"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("HelpPageIconUrl");
- else
- ViewState ["HelpPageIconUrl"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string HelpPageText
- {
- get
- {
- object o = ViewState ["HelpPageText"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("HelpPageText");
- else
- ViewState ["HelpPageText"] = value;
- }
- }
- public virtual string HelpPageUrl
- {
- get
- {
- object o = ViewState ["HelpPageUrl"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("HelpPageUrl");
- else
- ViewState ["HelpPageUrl"] = value;
- }
- }
- public TableItemStyle HyperLinkStyle
- {
- get
- {
- if (_hyperLinkStyle == null) {
- _hyperLinkStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _hyperLinkStyle).TrackViewState ();
- }
- return _hyperLinkStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string InstructionText
- {
- get
- {
- object o = ViewState ["InstructionText"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("InstructionText");
- else
- ViewState ["InstructionText"] = value;
- }
- }
- public TableItemStyle InstructionTextStyle
- {
- get
- {
- if (_instructionTextStyle == null) {
- _instructionTextStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _instructionTextStyle).TrackViewState ();
- }
- return _instructionTextStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string InvalidAnswerErrorMessage
- {
- get
- {
- object o = ViewState ["InvalidAnswerErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a different security answer.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("InvalidAnswerErrorMessage");
- else
- ViewState ["InvalidAnswerErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string InvalidEmailErrorMessage
- {
- get
- {
- object o = ViewState ["InvalidEmailErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a valid e-mail address.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("InvalidEmailErrorMessage");
- else
- ViewState ["InvalidEmailErrorMessage"] = value;
- }
- }
- [MonoTODO ("take the values from membership provider")]
- [LocalizableAttribute (true)]
- public virtual string InvalidPasswordErrorMessage
- {
- get
- {
- object o = ViewState ["InvalidPasswordErrorMessage"];
- return (o == null) ? Locale.GetText ("Password length minimum: {0}. Non-alphanumeric characters required: {1}.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("InvalidPasswordErrorMessage");
- else
- ViewState ["InvalidPasswordErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string InvalidQuestionErrorMessage
- {
- get
- {
- object o = ViewState ["InvalidQuestionErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a different security question.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("InvalidQuestionErrorMessage");
- else
- ViewState ["InvalidQuestionErrorMessage"] = value;
- }
- }
- public TableItemStyle LabelStyle
- {
- get
- {
- if (_labelStyle == null) {
- _labelStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _labelStyle).TrackViewState ();
- }
- return _labelStyle;
- }
- }
- [ThemeableAttribute (false)]
- public virtual bool LoginCreatedUser
- {
- get
- {
- object o = ViewState ["LoginCreatedUser"];
- return (o == null) ? true : (bool) o;
- }
- set
- {
- ViewState ["LoginCreatedUser"] = value;
- }
- }
- [ThemeableAttribute (false)]
- public MailDefinition MailDefinition {
- get {
- if (this._mailDefinition == null) {
- this._mailDefinition = new MailDefinition();
- if (IsTrackingViewState)
- ((IStateManager) _mailDefinition).TrackViewState ();
- }
- return _mailDefinition;
- }
- }
- [ThemeableAttribute (false)]
- public virtual string MembershipProvider
- {
- get
- {
- object o = ViewState ["MembershipProvider"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("MembershipProvider");
- else
- ViewState ["MembershipProvider"] = value;
- _provider = null;
- }
- }
- internal virtual MembershipProvider MembershipProviderInternal
- {
- get
- {
- if (_provider == null)
- InitMemberShipProvider ();
- return _provider;
- }
- }
- public virtual string Password
- {
- get { return _password; }
- }
- public TableItemStyle PasswordHintStyle
- {
- get
- {
- if (_passwordHintStyle == null) {
- _passwordHintStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _passwordHintStyle).TrackViewState ();
- }
- return _passwordHintStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string PasswordHintText
- {
- get
- {
- object o = ViewState ["PasswordHintText"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("PasswordHintText");
- else
- ViewState ["PasswordHintText"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string PasswordLabelText
- {
- get
- {
- object o = ViewState ["PasswordLabelText"];
- return (o == null) ? Locale.GetText ("Password:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("PasswordLabelText");
- else
- ViewState ["PasswordLabelText"] = value;
- }
- }
- public virtual string PasswordRegularExpression
- {
- get
- {
- object o = ViewState ["PasswordRegularExpression"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("PasswordRegularExpression");
- else
- ViewState ["PasswordRegularExpression"] = value;
- }
- }
- public virtual string PasswordRegularExpressionErrorMessage
- {
- get
- {
- object o = ViewState ["PasswordRegularExpressionErrorMessage"];
- return (o == null) ? Locale.GetText ("Please enter a different password.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("PasswordRegularExpressionErrorMessage");
- else
- ViewState ["PasswordRegularExpressionErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string PasswordRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["PasswordRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("Password is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("PasswordRequiredErrorMessage");
- else
- ViewState ["PasswordRequiredErrorMessage"] = value;
- }
- }
- [LocalizableAttribute (true)]
- [ThemeableAttribute (false)]
- public virtual string Question
- {
- get
- {
- object o = ViewState ["Question"];
- return (o == null) ? String.Empty : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("Question");
- else
- ViewState ["Question"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string QuestionLabelText
- {
- get
- {
- object o = ViewState ["QuestionLabelText"];
- return (o == null) ? Locale.GetText ("Security Question:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("QuestionLabelText");
- else
- ViewState ["QuestionLabelText"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string QuestionRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["QuestionRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("Security question is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("QuestionRequiredErrorMessage");
- else
- ViewState ["QuestionRequiredErrorMessage"] = value;
- }
- }
- [ThemeableAttribute (false)]
- public virtual bool RequireEmail
- {
- get
- {
- object o = ViewState ["RequireEmail"];
- return (o == null) ? true : (bool) o;
- }
- set
- {
- ViewState ["RequireEmail"] = value;
- }
- }
- [MonoTODO ("doesnt work")]
- public override string SkipLinkText
- {
- get
- {
- object o = ViewState ["SkipLinkText"];
- return (o == null) ? "" : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("SkipLinkText");
- else
- ViewState ["SkipLinkText"] = value;
- }
- }
- public Style TextBoxStyle
- {
- get
- {
- if (_textBoxStyle == null) {
- _textBoxStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager) _textBoxStyle).TrackViewState ();
- }
- return _textBoxStyle;
- }
- }
- public TableItemStyle TitleTextStyle
- {
- get
- {
- if (_titleTextStyle == null) {
- _titleTextStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager) _titleTextStyle).TrackViewState ();
- }
- return _titleTextStyle;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string UnknownErrorMessage
- {
- get
- {
- object o = ViewState ["UnknownErrorMessage"];
- return (o == null) ? Locale.GetText ("Your account was not created. Please try again.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("UnknownErrorMessage");
- else
- ViewState ["UnknownErrorMessage"] = value;
- }
- }
- public virtual string UserName
- {
- get
- {
- object o = ViewState ["UserName"];
- return (o == null) ? String.Empty : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("UserName");
- else
- ViewState ["UserName"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string UserNameLabelText
- {
- get
- {
- object o = ViewState ["UserNameLabelText"];
- return (o == null) ? Locale.GetText ("User Name:") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("UserNameLabelText");
- else
- ViewState ["UserNameLabelText"] = value;
- }
- }
- [LocalizableAttribute (true)]
- public virtual string UserNameRequiredErrorMessage
- {
- get
- {
- object o = ViewState ["UserNameRequiredErrorMessage"];
- return (o == null) ? Locale.GetText ("User Name is required.") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("UserNameRequiredErrorMessage");
- else
- ViewState ["UserNameRequiredErrorMessage"] = value;
- }
- }
- public Style ValidatorTextStyle
- {
- get
- {
- if (_validatorTextStyle == null) {
- _validatorTextStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager) _validatorTextStyle).TrackViewState ();
- }
- return _validatorTextStyle;
- }
- }
- [ThemeableAttribute (false)]
- public override WizardStepCollection WizardSteps
- {
- get { return base.WizardSteps; }
- }
- #endregion
- #region Protected Properties
- protected internal bool QuestionAndAnswerRequired
- {
- get { return MembershipProviderInternal.RequiresQuestionAndAnswer; }
- }
- public event EventHandler ContinueButtonClick
- {
- add { Events.AddHandler (ContinueButtonClickEvent, value); }
- remove { Events.RemoveHandler (ContinueButtonClickEvent, value); }
- }
- public event EventHandler CreatedUser
- {
- add { Events.AddHandler (CreatedUserEvent, value); }
- remove { Events.RemoveHandler (CreatedUserEvent, value); }
- }
- public event CreateUserErrorEventHandler CreateUserError
- {
- add { Events.AddHandler (CreateUserErrorEvent, value); }
- remove { Events.RemoveHandler (CreateUserErrorEvent, value); }
- }
- public event LoginCancelEventHandler CreatingUser
- {
- add { Events.AddHandler (CreatingUserEvent, value); }
- remove { Events.RemoveHandler (CreatingUserEvent, value); }
- }
- public event MailMessageEventHandler SendingMail
- {
- add { Events.AddHandler (SendingMailEvent, value); }
- remove { Events.RemoveHandler (SendingMailEvent, value); }
- }
- public event SendMailErrorEventHandler SendMailError
- {
- add { Events.AddHandler (SendMailErrorEvent, value); }
- remove { Events.RemoveHandler (SendMailErrorEvent, value); }
- }
- #endregion
- #region Internal Properties
- internal override void InstantiateTemplateStep (TemplatedWizardStep step)
- {
- if (step is CreateUserWizardStep) {
- InstantiateCreateUserWizardStep ((CreateUserWizardStep) step);
- }
- else if (step is CompleteWizardStep) {
- InstantiateCompleteWizardStep ((CompleteWizardStep) step);
- }
- else {
- base.InstantiateTemplateStep (step);
- }
- }
- private void InstantiateCompleteWizardStep (CompleteWizardStep step)
- {
- CompleteStepContainer contentTemplateContainer = new CompleteStepContainer (this);
- if (step.ContentTemplate != null) {
- step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
- }
- else {
- new CompleteStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
- contentTemplateContainer.ConfirmDefaultTemplate ();
- }
- step.ContentTemplateContainer = contentTemplateContainer;
- step.Controls.Clear ();
- step.Controls.Add (contentTemplateContainer);
- BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
- if (step.CustomNavigationTemplate != null) {
- step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
- RegisterCustomNavigation (step, customNavigationTemplateContainer);
- }
- step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
- }
- void InstantiateCreateUserWizardStep (CreateUserWizardStep step)
- {
- CreateUserStepContainer contentTemplateContainer = new CreateUserStepContainer (this);
- if (step.ContentTemplate != null) {
- step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
- }
- else {
- new CreateUserStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
- contentTemplateContainer.ConfirmDefaultTemplate ();
- contentTemplateContainer.EnsureValidatorsState ();
- }
- step.ContentTemplateContainer = contentTemplateContainer;
- step.Controls.Clear ();
- step.Controls.Add (contentTemplateContainer);
- CreateUserNavigationContainer customNavigationTemplateContainer = new CreateUserNavigationContainer (this);
- if (step.CustomNavigationTemplate != null) {
- step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
- }
- else {
- new CreateUserStepNavigationTemplate (this).InstantiateIn (customNavigationTemplateContainer);
- customNavigationTemplateContainer.ConfirmDefaultTemplate ();
- }
- RegisterCustomNavigation (step, customNavigationTemplateContainer);
- step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
- }
-
- internal override ITemplate SideBarItemTemplate
- {
- get { return new SideBarLabelTemplate (this); }
- }
- #endregion
- #region Protected Methods
- protected internal override void CreateChildControls ()
- {
- if (CreateUserStep == null)
- WizardSteps.AddAt (0, new CreateUserWizardStep ());
- if (CompleteStep == null)
- WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
- base.CreateChildControls ();
- }
- protected override void CreateControlHierarchy ()
- {
- base.CreateControlHierarchy ();
- CreateUserStepContainer container = CreateUserStep.ContentTemplateContainer as CreateUserStepContainer;
- if (container != null) {
- IEditableTextControl editable;
- editable = container.UserNameTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (UserName_TextChanged);
- if (!AutoGeneratePassword) {
- editable = container.PasswordTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (Password_TextChanged);
- editable = container.ConfirmPasswordTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (ConfirmPassword_TextChanged);
- }
- if (RequireEmail) {
- editable = container.EmailTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (Email_TextChanged);
- }
- if (QuestionAndAnswerRequired) {
- editable = container.QuestionTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (Question_TextChanged);
- editable = container.AnswerTextBox as IEditableTextControl;
- if (editable != null)
- editable.TextChanged += new EventHandler (Answer_TextChanged);
- }
- _errorMessageLabel = container.ErrorMessageLabel;
- }
- }
- [MonoTODO ("Not Implemented")]
- protected override IDictionary GetDesignModeState ()
- {
- throw new NotImplementedException ();
- }
- protected override bool OnBubbleEvent (object source, EventArgs e)
- {
- CommandEventArgs args = e as CommandEventArgs;
- if (e != null && args.CommandName == ContinueButtonCommandName) {
- ProcessContinueEvent ();
- return true;
- }
- return base.OnBubbleEvent (source, e);
- }
- private void ProcessContinueEvent () {
- OnContinueButtonClick (EventArgs.Empty);
- if (ContinueDestinationPageUrl.Length > 0) {
- Context.Response.Redirect (ContinueDestinationPageUrl);
- }
- }
- protected virtual void OnContinueButtonClick (EventArgs e)
- {
- if (Events != null) {
- EventHandler eh = (EventHandler) Events [ContinueButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected virtual void OnCreatedUser (EventArgs e)
- {
- if (Events != null) {
- EventHandler eh = (EventHandler) Events [CreatedUserEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected virtual void OnCreateUserError (CreateUserErrorEventArgs e)
- {
- if (Events != null) {
- CreateUserErrorEventHandler eh = (CreateUserErrorEventHandler) Events [CreateUserErrorEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected virtual void OnCreatingUser (LoginCancelEventArgs e)
- {
- if (Events != null) {
- LoginCancelEventHandler eh = (LoginCancelEventHandler) Events [CreatingUserEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected override void OnNextButtonClick (WizardNavigationEventArgs e)
- {
- if (ActiveStep == CreateUserStep) {
- bool userCreated = CreateUser ();
- if (!userCreated)
- e.Cancel = true;
- else
- if (LoginCreatedUser)
- Login ();
- }
- base.OnNextButtonClick (e);
- }
- protected internal override void OnPreRender (EventArgs e)
- {
- base.OnPreRender (e);
- }
- protected virtual void OnSendingMail (MailMessageEventArgs e)
- {
- if (Events != null) {
- MailMessageEventHandler eh = (MailMessageEventHandler) Events [SendingMailEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected virtual void OnSendMailError (SendMailErrorEventArgs e)
- {
- if (Events != null) {
- SendMailErrorEventHandler eh = (SendMailErrorEventHandler) Events [SendMailErrorEvent];
- if (eh != null) eh (this, e);
- }
- }
- protected override void LoadViewState (object savedState)
- {
- if (savedState == null) {
- base.LoadViewState (null);
- return;
- }
- object [] states = (object []) savedState;
- base.LoadViewState (states [0]);
- if (states [1] != null)
- ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
- if (states [2] != null)
- ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
- if (states [3] != null)
- ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
- if (states [4] != null)
- ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
- if (states [5] != null)
- ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
- if (states [6] != null)
- ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
- if (states [7] != null)
- ((IStateManager) LabelStyle).LoadViewState (states [7]);
- if (states [8] != null)
- ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
- if (states [9] != null)
- ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
- if (states [10] != null)
- ((IStateManager) CreateUserButtonStyle).LoadViewState (states [10]);
- if (states [11] != null)
- ((IStateManager) ContinueButtonStyle).LoadViewState (states [11]);
- if (states [12] != null)
- ((IStateManager) MailDefinition).LoadViewState (states [12]);
- ((CreateUserStepContainer) CreateUserStep.ContentTemplateContainer).EnsureValidatorsState ();
- }
- protected override object SaveViewState ()
- {
- object [] state = new object [13];
- state [0] = base.SaveViewState ();
- if (_textBoxStyle != null)
- state [1] = ((IStateManager) _textBoxStyle).SaveViewState ();
- if (_validatorTextStyle != null)
- state [2] = ((IStateManager) _validatorTextStyle).SaveViewState ();
- if (_completeSuccessTextStyle != null)
- state [3] = ((IStateManager) _completeSuccessTextStyle).SaveViewState ();
- if (_errorMessageStyle != null)
- state [4] = ((IStateManager) _errorMessageStyle).SaveViewState ();
- if (_hyperLinkStyle != null)
- state [5] = ((IStateManager) _hyperLinkStyle).SaveViewState ();
- if (_instructionTextStyle != null)
- state [6] = ((IStateManager) _instructionTextStyle).SaveViewState ();
- if (_labelStyle != null)
- state [7] = ((IStateManager) _labelStyle).SaveViewState ();
- if (_passwordHintStyle != null)
- state [8] = ((IStateManager) _passwordHintStyle).SaveViewState ();
- if (_titleTextStyle != null)
- state [9] = ((IStateManager) _titleTextStyle).SaveViewState ();
- if (_createUserButtonStyle != null)
- state [10] = ((IStateManager) _createUserButtonStyle).SaveViewState ();
- if (_continueButtonStyle != null)
- state [11] = ((IStateManager) _continueButtonStyle).SaveViewState ();
- if (_mailDefinition != null)
- state [12] = ((IStateManager) _mailDefinition).SaveViewState ();
- for (int n = 0; n < state.Length; n++)
- if (state [n] != null)
- return state;
- return null;
- }
- [MonoTODO ("for design-time usage - no more details available")]
- protected override void SetDesignModeState (IDictionary data)
- {
- base.SetDesignModeState (data);
- }
- protected override void TrackViewState ()
- {
- base.TrackViewState ();
- if (_textBoxStyle != null)
- ((IStateManager) _textBoxStyle).TrackViewState ();
- if (_validatorTextStyle != null)
- ((IStateManager) _validatorTextStyle).TrackViewState ();
- if (_completeSuccessTextStyle != null)
- ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
- if (_errorMessageStyle != null)
- ((IStateManager) _errorMessageStyle).TrackViewState ();
- if (_hyperLinkStyle != null)
- ((IStateManager) _hyperLinkStyle).TrackViewState ();
- if (_instructionTextStyle != null)
- ((IStateManager) _instructionTextStyle).TrackViewState ();
- if (_labelStyle != null)
- ((IStateManager) _labelStyle).TrackViewState ();
- if (_passwordHintStyle != null)
- ((IStateManager) _passwordHintStyle).TrackViewState ();
- if (_titleTextStyle != null)
- ((IStateManager) _titleTextStyle).TrackViewState ();
- if (_createUserButtonStyle != null)
- ((IStateManager) _createUserButtonStyle).TrackViewState ();
- if (_continueButtonStyle != null)
- ((IStateManager) _continueButtonStyle).TrackViewState ();
- if (_mailDefinition != null)
- ((IStateManager) _mailDefinition).TrackViewState ();
- }
- #endregion
- #region Private event handlers
- private void UserName_TextChanged (object sender, EventArgs e)
- {
- UserName = ((ITextControl) sender).Text;
- }
- private void Password_TextChanged (object sender, EventArgs e)
- {
- _password = ((ITextControl) sender).Text;
- }
- private void ConfirmPassword_TextChanged (object sender, EventArgs e)
- {
- _confirmPassword = ((ITextControl) sender).Text;
- }
- private void Email_TextChanged (object sender, EventArgs e)
- {
- Email = ((ITextControl) sender).Text;
- }
- private void Question_TextChanged (object sender, EventArgs e)
- {
- Question = ((ITextControl) sender).Text;
- }
- private void Answer_TextChanged (object sender, EventArgs e)
- {
- Answer = ((ITextControl) sender).Text;
- }
- #endregion
- #region Private Methods
- private void InitMemberShipProvider ()
- {
- string mp = MembershipProvider;
- _provider = (mp.Length == 0) ? _provider = Membership.Provider : Membership.Providers [mp];
- if (_provider == null)
- throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
- }
- private bool CreateUser ()
- {
- if (!Page.IsValid)
- return false;
- if (AutoGeneratePassword)
- _password = GeneratePassword ();
- OnCreatingUser (new LoginCancelEventArgs (false));
- MembershipCreateStatus status;
- MembershipUser newUser = MembershipProviderInternal.CreateUser (
- UserName, Password, Email, Question, Answer, !DisableCreatedUser, null, out status);
- if ((newUser != null) && (status == MembershipCreateStatus.Success)) {
- OnCreatedUser (new EventArgs ());
- SendPasswordByMail (newUser, Password);
- return true;
- }
- switch (status) {
- case MembershipCreateStatus.DuplicateUserName:
- ShowErrorMessage (DuplicateUserNameErrorMessage);
- break;
- case MembershipCreateStatus.InvalidPassword:
- ShowErrorMessage (String.Format (InvalidPasswordErrorMessage, MembershipProviderInternal.MinRequiredPasswordLength, MembershipProviderInternal.MinRequiredNonAlphanumericCharacters));
- break;
- case MembershipCreateStatus.DuplicateEmail:
- ShowErrorMessage (DuplicateEmailErrorMessage);
- break;
- case MembershipCreateStatus.InvalidEmail:
- ShowErrorMessage (InvalidEmailErrorMessage);
- break;
- case MembershipCreateStatus.InvalidQuestion:
- ShowErrorMessage (InvalidQuestionErrorMessage);
- break;
- case MembershipCreateStatus.InvalidAnswer:
- ShowErrorMessage (InvalidAnswerErrorMessage);
- break;
- case MembershipCreateStatus.UserRejected:
- case MembershipCreateStatus.InvalidUserName:
- case MembershipCreateStatus.ProviderError:
- case MembershipCreateStatus.InvalidProviderUserKey:
- ShowErrorMessage (UnknownErrorMessage);
- break;
- }
- OnCreateUserError (new CreateUserErrorEventArgs (status));
- return false;
- }
- private void SendPasswordByMail (MembershipUser user, string password)
- {
- if (user == null)
- return;
-
- if (_mailDefinition == null)
- return;
-
- string messageText = "A new account has been created for you. Please go to the site and log in using the following information.\nUser Name: <%USERNAME%>\nPassword: <%PASSWORD%>";
- ListDictionary dictionary = new ListDictionary ();
- dictionary.Add ("<%USERNAME%>", user.UserName);
- dictionary.Add ("<%PASSWORD%>", password);
- MailMessage message = null;
-
- if (MailDefinition.BodyFileName.Length == 0)
- message = MailDefinition.CreateMailMessage (user.Email, dictionary, messageText, this);
- else
- message = MailDefinition.CreateMailMessage (user.Email, dictionary, this);
- if (string.IsNullOrEmpty (message.Subject))
- message.Subject = "Account information";
- MailMessageEventArgs args = new MailMessageEventArgs (message);
- OnSendingMail (args);
- SmtpClient smtpClient = new SmtpClient ();
- try {
- smtpClient.Send (message);
- } catch (Exception e) {
- SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e);
- OnSendMailError (mailArgs);
- if (!mailArgs.Handled)
- throw e;
- }
- }
- private void Login ()
- {
- bool userValidated = MembershipProviderInternal.ValidateUser (UserName, Password);
- if (userValidated)
- FormsAuthentication.SetAuthCookie (UserName, false);
- }
- private void ShowErrorMessage (string errorMessage)
- {
- if (_errorMessageLabel != null)
- _errorMessageLabel.Text = errorMessage;
- }
- private string GeneratePassword ()
- {
- return Membership.GeneratePassword (8, 3);
- }
- #endregion
- #region SideBarLabelTemplate
- class SideBarLabelTemplate : ITemplate
- {
- Wizard wizard;
- public SideBarLabelTemplate (Wizard wizard)
- {
- this.wizard = wizard;
- }
- public void InstantiateIn (Control control)
- {
- Label b = new Label ();
- wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
- control.Controls.Add (b);
- control.DataBinding += Bound;
- }
- void Bound (object s, EventArgs args)
- {
- WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
- if (step != null) {
- Control c = (Control) s;
- Label b = (Label) c.Controls [0];
- b.ID = SideBarButtonID;
- b.Text = step.Title;
- }
- }
- }
- #endregion
- sealed class CreateUserNavigationContainer : DefaultNavigationContainer
- {
- CreateUserWizard _createUserWizard;
- public CreateUserNavigationContainer (CreateUserWizard createUserWizard)
- : base (createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
- protected override void UpdateState ()
- {
- // previous
- if (_createUserWizard.AllowNavigationToStep (_createUserWizard.ActiveStepIndex - 1)) {
- UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
- }
- // create user
- UpdateNavButtonState (Wizard.StepNextButtonID + _createUserWizard.CreateUserButtonType, _createUserWizard.CreateUserButtonText, _createUserWizard.CreateUserButtonImageUrl, _createUserWizard.CreateUserButtonStyle);
- // cancel
- if (Wizard.DisplayCancelButton) {
- UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
- }
- }
- }
- sealed class CreateUserStepNavigationTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
- public CreateUserStepNavigationTemplate (CreateUserWizard createUserWizard) {
- _createUserWizard = createUserWizard;
- }
- #region ITemplate Members
- public void InstantiateIn (Control container) {
- Table t = new Table ();
- t.CellPadding = 5;
- t.CellSpacing = 5;
- t.Width = Unit.Percentage (100);
- t.Height = Unit.Percentage (100);
- TableRow row = new TableRow ();
- AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepPreviousButtonID, Wizard.MovePreviousCommandName, false));
- AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepNextButtonID, Wizard.MoveNextCommandName));
- AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.CancelButtonID, Wizard.CancelCommandName, false));
-
- t.Rows.Add (row);
- container.Controls.Add (t);
- }
- void AddButtonCell (TableRow row, params Control [] controls)
- {
- TableCell cell = new TableCell ();
- cell.HorizontalAlign = HorizontalAlign.Right;
- for (int i = 0; i < controls.Length; i++)
- cell.Controls.Add (controls[i]);
- row.Cells.Add (cell);
- }
- #endregion
- }
- sealed class CreateUserStepContainer : DefaultContentContainer
- {
- CreateUserWizard _createUserWizard;
- public CreateUserStepContainer (CreateUserWizard createUserWizard)
- : base (createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
- public Control UserNameTextBox {
- get {
- Control c = FindControl ("UserName");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID UserName for the username.");
- return c;
- }
- }
- public Control PasswordTextBox {
- get {
- Control c = FindControl ("Password");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Password for the new password, this is required if AutoGeneratePassword = true.");
- return c;
- }
- }
- public Control ConfirmPasswordTextBox {
- get {
- Control c = FindControl ("Password");
- return c;
- }
- }
- public Control EmailTextBox {
- get {
- Control c = FindControl ("Email");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.");
- return c;
- }
- }
- public Control QuestionTextBox {
- get {
- Control c = FindControl ("Question");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Question for the security question, this is required if your membership provider requires a question and answer.");
- return c;
- }
- }
- public Control AnswerTextBox {
- get {
- Control c = FindControl ("Answer");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Answer for the security answer, this is required if your membership provider requires a question and answer.");
- return c;
- }
- }
- public ITextControl ErrorMessageLabel {
- get { return FindControl ("ErrorMessage") as ITextControl; }
- }
- protected override void UpdateState () {
- // Row #0 - title
- if (String.IsNullOrEmpty (_createUserWizard.CreateUserStep.Title)) {
- ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CreateUserStep.Title;
- }
- // Row #1 - InstructionText
- if (String.IsNullOrEmpty (_createUserWizard.InstructionText)) {
- ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.InstructionText;
- }
- // Row #2
- Label UserNameLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [2].Cells [0].Controls [0];
- UserNameLabel.Text = _createUserWizard.UserNameLabelText;
- RequiredFieldValidator UserNameRequired = (RequiredFieldValidator) FindControl ("UserNameRequired");
- UserNameRequired.ErrorMessage = _createUserWizard.UserNameRequiredErrorMessage;
- UserNameRequired.ToolTip = _createUserWizard.UserNameRequiredErrorMessage;
- if (_createUserWizard.AutoGeneratePassword) {
- ((Table) InnerCell.Controls [0]).Rows [3].Visible = false;
- ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
- ((Table) InnerCell.Controls [0]).Rows [5].Visible = false;
- }
- else {
- // Row #3
- Label PasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
- PasswordLabel.Text = _createUserWizard.PasswordLabelText;
- RequiredFieldValidator PasswordRequired = (RequiredFieldValidator) FindControl ("PasswordRequired");
- PasswordRequired.ErrorMessage = _createUserWizard.PasswordRequiredErrorMessage;
- PasswordRequired.ToolTip = _createUserWizard.PasswordRequiredErrorMessage;
- // Row #4
- if (String.IsNullOrEmpty (_createUserWizard.PasswordHintText)) {
- ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [4].Cells [1].Text = _createUserWizard.PasswordHintText;
- }
- // Row #5
- Label ConfirmPasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [5].Cells [0].Controls [0];
- ConfirmPasswordLabel.Text = _createUserWizard.ConfirmPasswordLabelText;
- RequiredFieldValidator ConfirmPasswordRequired = (RequiredFieldValidator) FindControl ("ConfirmPasswordRequired");
- ConfirmPasswordRequired.ErrorMessage = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
- ConfirmPasswordRequired.ToolTip = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
- }
- // Row #6
- if (_createUserWizard.RequireEmail) {
- Label EmailLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [6].Cells [0].Controls [0];
- EmailLabel.Text = _createUserWizard.EmailLabelText;
- RequiredFieldValidator EmailRequired = (RequiredFieldValidator) FindControl ("EmailRequired");
- EmailRequired.ErrorMessage = _createUserWizard.EmailRequiredErrorMessage;
- EmailRequired.ToolTip = _createUserWizard.EmailRequiredErrorMessage;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [6].Visible = false;
- }
- if (_createUserWizard.QuestionAndAnswerRequired) {
- // Row #7
- Label QuestionLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [7].Cells [0].Controls [0];
- QuestionLabel.Text = _createUserWizard.QuestionLabelText;
- RequiredFieldValidator QuestionRequired = (RequiredFieldValidator) FindControl ("QuestionRequired");
- QuestionRequired.ErrorMessage = _createUserWizard.QuestionRequiredErrorMessage;
- QuestionRequired.ToolTip = _createUserWizard.QuestionRequiredErrorMessage;
- // Row #8
- Label AnswerLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [8].Cells [0].Controls [0];
- AnswerLabel.Text = _createUserWizard.AnswerLabelText;
- RequiredFieldValidator AnswerRequired = (RequiredFieldValidator) FindControl ("AnswerRequired");
- AnswerRequired.ErrorMessage = _createUserWizard.AnswerRequiredErrorMessage;
- AnswerRequired.ToolTip = _createUserWizard.AnswerRequiredErrorMessage;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [7].Visible = false;
- ((Table) InnerCell.Controls [0]).Rows [8].Visible = false;
- }
- // Row #9
- if (_createUserWizard.AutoGeneratePassword) {
- ((Table) InnerCell.Controls [0]).Rows [9].Visible = false;
- }
- else {
- CompareValidator PasswordCompare = (CompareValidator) FindControl ("PasswordCompare");
- PasswordCompare.ErrorMessage = _createUserWizard.ConfirmPasswordCompareErrorMessage;
- }
- // Row #10
- if (_createUserWizard.AutoGeneratePassword || String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression)) {
- ((Table) InnerCell.Controls [0]).Rows [10].Visible = false;
- }
- else {
- RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
- PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
- PasswordRegEx.ErrorMessage = _createUserWizard.PasswordRegularExpressionErrorMessage;
- }
- // Row #11
- if (!_createUserWizard.RequireEmail || String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression)) {
- ((Table) InnerCell.Controls [0]).Rows [11].Visible = false;
- }
- else {
- RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
- EmailRegEx.ErrorMessage = _createUserWizard.EmailRegularExpressionErrorMessage;
- EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
- }
- // Row #12
- if (String.IsNullOrEmpty (ErrorMessageLabel.Text)) {
- ((Table) InnerCell.Controls [0]).Rows [12].Visible = false;
- }
- // Row #13
- // HelpPageIconUrl
- Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [0];
- if (String.IsNullOrEmpty (_createUserWizard.HelpPageIconUrl)) {
- img.Visible = false;
- }
- else {
- img.ImageUrl = _createUserWizard.HelpPageIconUrl;
- img.AlternateText = _createUserWizard.HelpPageText;
- }
- // HelpPageText
- HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [1];
- if (String.IsNullOrEmpty (_createUserWizard.HelpPageText)) {
- link.Visible = false;
- }
- else {
- link.Text = _createUserWizard.HelpPageText;
- link.NavigateUrl = _createUserWizard.HelpPageUrl;
- }
- ((Table) InnerCell.Controls [0]).Rows [13].Visible = img.Visible || link.Visible;
- }
- public void EnsureValidatorsState ()
- {
- if (!IsDefaultTemplate)
- return;
- ((RequiredFieldValidator) FindControl ("PasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
- ((RequiredFieldValidator) FindControl ("ConfirmPasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
- ((CompareValidator) FindControl ("PasswordCompare")).Enabled = !_createUserWizard.AutoGeneratePassword;
- RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
- PasswordRegEx.Enabled = !_createUserWizard.AutoGeneratePassword && !String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression);
- PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
- ((RequiredFieldValidator) FindControl ("EmailRequired")).Enabled = _createUserWizard.RequireEmail;
- RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
- EmailRegEx.Enabled = _createUserWizard.RequireEmail && !String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression);
- EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
- ((RequiredFieldValidator) FindControl ("QuestionRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
- ((RequiredFieldValidator) FindControl ("AnswerRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
- }
- }
- sealed class CreateUserStepTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
- public CreateUserStepTemplate (CreateUserWizard createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
- #region ITemplate Members
- TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1) {
- TableRow row = new TableRow ();
- TableCell cell0 = new TableCell ();
- TableCell cell1 = new TableCell ();
- if (c0 != null)
- cell0.Controls.Add (c0);
- row.Controls.Add (cell0);
- if ((c1 != null) && (c2 != null)) {
- cell1.Controls.Add (c1);
- cell1.Controls.Add (c2);
- cell0.HorizontalAlign = HorizontalAlign.Right;
- if (s0 != null)
- _createUserWizard.RegisterApplyStyle (cell0, s0);
- if (s1 != null)
- _createUserWizard.RegisterApplyStyle (cell1, s1);
- row.Controls.Add (cell1);
- }
- else {
- cell0.ColumnSpan = 2;
- cell0.HorizontalAlign = HorizontalAlign.Center;
- if (s0 != null)
- _createUserWizard.RegisterApplyStyle (cell0, s0);
- }
- return row;
- }
- public void InstantiateIn (Control container) {
- Table table = new Table ();
- table.ControlStyle.Width = Unit.Percentage (100);
- table.ControlStyle.Height = Unit.Percentage (100);
- // Row #0
- table.Controls.Add (CreateRow (null, null, null, _createUserWizard.TitleTextStyle, null));
- // Row #1
- table.Controls.Add (CreateRow (null, null, null, _createUserWizard.InstructionTextStyle, null));
- // Row #2
- TextBox UserName = new TextBox ();
- UserName.ID = "UserName";
- _createUserWizard.RegisterApplyStyle (UserName, _createUserWizard.TextBoxStyle);
- Label UserNameLabel = new Label ();
- UserNameLabel.AssociatedControlID = "UserName";
- RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
- UserNameRequired.ID = "UserNameRequired";
- // alternatively we can create only required validators
- // and reinstantiate collection when relevant property changes
- UserNameRequired.EnableViewState = false;
- UserNameRequired.ControlToValidate = "UserName";
- UserNameRequired.Text = "*";
- UserNameRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (UserNameRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _createUserWizard.LabelStyle, null));
- // Row #3
- TextBox Password = new TextBox ();
- Password.ID = "Password";
- Password.TextMode = TextBoxMode.Password;
- _createUserWizard.RegisterApplyStyle (Password, _createUserWizard.TextBoxStyle);
- Label PasswordLabel = new Label ();
- PasswordLabel.AssociatedControlID = "Password";
- RequiredFieldValidator PasswordRequired = new RequiredFieldValidator ();
- PasswordRequired.ID = "PasswordRequired";
- PasswordRequired.EnableViewState = false;
- PasswordRequired.ControlToValidate = "Password";
- PasswordRequired.Text = "*";
- //PasswordRequired.EnableViewState = false;
- PasswordRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (PasswordRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (PasswordLabel, Password, PasswordRequired, _createUserWizard.LabelStyle, null));
- // Row #4
- table.Controls.Add (CreateRow (new LiteralControl (""), new LiteralControl (""), new LiteralControl (""), null, _createUserWizard.PasswordHintStyle));
- // Row #5
- TextBox ConfirmPassword = new TextBox ();
- ConfirmPassword.ID = "ConfirmPassword";
- ConfirmPassword.TextMode = TextBoxMode.Password;
- _createUserWizard.RegisterApplyStyle (ConfirmPassword, _createUserWizard.TextBoxStyle);
- Label ConfirmPasswordLabel = new Label ();
- ConfirmPasswordLabel.AssociatedControlID = "ConfirmPassword";
- RequiredFieldValidator ConfirmPasswordRequired = new RequiredFieldValidator ();
- ConfirmPasswordRequired.ID = "ConfirmPasswordRequired";
- ConfirmPasswordRequired.EnableViewState = false;
- ConfirmPasswordRequired.ControlToValidate = "ConfirmPassword";
- ConfirmPasswordRequired.Text = "*";
- ConfirmPasswordRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (ConfirmPasswordRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (ConfirmPasswordLabel, ConfirmPassword, ConfirmPasswordRequired, _createUserWizard.LabelStyle, null));
- // Row #6
- TextBox Email = new TextBox ();
- Email.ID = "Email";
- _createUserWizard.RegisterApplyStyle (Email, _createUserWizard.TextBoxStyle);
- Label EmailLabel = new Label ();
- EmailLabel.AssociatedControlID = "Email";
- RequiredFieldValidator EmailRequired = new RequiredFieldValidator ();
- EmailRequired.ID = "EmailRequired";
- EmailRequired.EnableViewState = false;
- EmailRequired.ControlToValidate = "Email";
- EmailRequired.Text = "*";
- EmailRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (EmailRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (EmailLabel, Email, EmailRequired, _createUserWizard.LabelStyle, null));
- // Row #7
- TextBox Question = new TextBox ();
- Question.ID = "Question";
- _createUserWizard.RegisterApplyStyle (Question, _createUserWizard.TextBoxStyle);
- Label QuestionLabel = new Label ();
- QuestionLabel.AssociatedControlID = "Question";
- RequiredFieldValidator QuestionRequired = new RequiredFieldValidator ();
- QuestionRequired.ID = "QuestionRequired";
- QuestionRequired.EnableViewState = false;
- QuestionRequired.ControlToValidate = "Question";
- QuestionRequired.Text = "*";
- QuestionRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (QuestionRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (QuestionLabel, Question, QuestionRequired, _createUserWizard.LabelStyle, null));
- // Row #8
- TextBox Answer = new TextBox ();
- Answer.ID = "Answer";
- _createUserWizard.RegisterApplyStyle (Answer, _createUserWizard.TextBoxStyle);
- Label AnswerLabel = new Label ();
- AnswerLabel.AssociatedControlID = "Answer";
- RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
- AnswerRequired.ID = "AnswerRequired";
- AnswerRequired.EnableViewState = false;
- AnswerRequired.ControlToValidate = "Answer";
- AnswerRequired.Text = "*";
- AnswerRequired.ValidationGroup = _createUserWizard.ID;
- _createUserWizard.RegisterApplyStyle (AnswerRequired, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (AnswerLabel, Answer, AnswerRequired, _createUserWizard.LabelStyle, null));
- // Row #9
- CompareValidator PasswordCompare = new CompareValidator ();
- PasswordCompare.ID = "PasswordCompare";
- PasswordCompare.EnableViewState = false;
- PasswordCompare.ControlToCompare = "Password";
- PasswordCompare.ControlToValidate = "ConfirmPassword";
- PasswordCompare.Display = ValidatorDisplay.Static;
- PasswordCompare.ValidationGroup = _createUserWizard.ID;
- PasswordCompare.Display = ValidatorDisplay.Dynamic;
- _createUserWizard.RegisterApplyStyle (PasswordCompare, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (PasswordCompare, null, null, null, null));
- // Row #10
- RegularExpressionValidator PasswordRegEx = new RegularExpressionValidator ();
- PasswordRegEx.ID = "PasswordRegEx";
- PasswordRegEx.EnableViewState = false;
- PasswordRegEx.ControlToValidate = "Password";
- PasswordRegEx.Display = ValidatorDisplay.Static;
- PasswordRegEx.ValidationGroup = _createUserWizard.ID;
- PasswordRegEx.Display = ValidatorDisplay.Dynamic;
- _createUserWizard.RegisterApplyStyle (PasswordRegEx, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (PasswordRegEx, null, null, null, null));
- // Row #11
- RegularExpressionValidator EmailRegEx = new RegularExpressionValidator ();
- EmailRegEx.ID = "EmailRegEx";
- EmailRegEx.EnableViewState = false;
- EmailRegEx.ControlToValidate = "Email";
- EmailRegEx.Display = ValidatorDisplay.Static;
- EmailRegEx.ValidationGroup = _createUserWizard.ID;
- EmailRegEx.Display = ValidatorDisplay.Dynamic;
- _createUserWizard.RegisterApplyStyle (EmailRegEx, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (EmailRegEx, null, null, null, null));
- // Row #12
- Label ErrorMessage = new Label ();
- ErrorMessage.ID = "ErrorMessage";
- ErrorMessage.EnableViewState = false;
- _createUserWizard.RegisterApplyStyle (ErrorMessage, _createUserWizard.ValidatorTextStyle);
- table.Controls.Add (CreateRow (ErrorMessage, null, null, null, null));
- // Row #13
- TableRow row13 = CreateRow (new Image (), null, null, null, null);
- HyperLink HelpLink = new HyperLink ();
- HelpLink.ID = "HelpLink";
- _createUserWizard.RegisterApplyStyle (HelpLink, _createUserWizard.HyperLinkStyle);
- row13.Cells [0].Controls.Add (HelpLink);
- row13.Cells [0].HorizontalAlign = HorizontalAlign.Left;
- table.Controls.Add (row13);
- //
- container.Controls.Add (table);
- }
- #endregion
- }
- sealed class CompleteStepContainer : DefaultContentContainer
- {
- CreateUserWizard _createUserWizard;
- public CompleteStepContainer (CreateUserWizard createUserWizard)
- : base (createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
- protected override void UpdateState ()
- {
- // title
- if (String.IsNullOrEmpty (_createUserWizard.CompleteStep.Title)) {
- ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CompleteStep.Title;
- }
- // CompleteSuccessText
- if (String.IsNullOrEmpty (_createUserWizard.CompleteSuccessText)) {
- ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
- }
- else {
- ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.CompleteSuccessText;
- }
- // ContinueButton
- UpdateNavButtonState ("ContinueButton" + _createUserWizard.ContinueButtonType, _createUserWizard.ContinueButtonText, _createUserWizard.ContinueButtonImageUrl, _createUserWizard.ContinueButtonStyle);
- // EditProfileIconUrl
- Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
- if (String.IsNullOrEmpty (_createUserWizard.EditProfileIconUrl)) {
- img.Visible = false;
- }
- else {
- img.ImageUrl = _createUserWizard.EditProfileIconUrl;
- img.AlternateText = _createUserWizard.EditProfileText;
- }
- // EditProfileText
- HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [1];
- if (String.IsNullOrEmpty (_createUserWizard.EditProfileText)) {
- link.Visible = false;
- }
- else {
- link.Text = _createUserWizard.EditProfileText;
- link.NavigateUrl = _createUserWizard.EditProfileUrl;
- }
- ((Table) InnerCell.Controls [0]).Rows [3].Visible = img.Visible || link.Visible;
- }
-
- void UpdateNavButtonState (string id, string text, string image, Style style)
- {
- WebControl b = (WebControl) FindControl (id);
- foreach (Control c in b.Parent.Controls)
- c.Visible = b == c;
- ((IButtonControl) b).Text = text;
- ImageButton imgbtn = b as ImageButton;
- if (imgbtn != null)
- imgbtn.ImageUrl = image;
- b.ApplyStyle (style);
- }
- }
- sealed class CompleteStepTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
- public CompleteStepTemplate (CreateUserWizard createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
- #region ITemplate Members
- public void InstantiateIn (Control container)
- {
- Table table = new Table ();
- // Row #0
- TableRow row0 = new TableRow ();
- TableCell cell00 = new TableCell ();
- cell00.HorizontalAlign = HorizontalAlign.Center;
- cell00.ColumnSpan = 2;
- _createUserWizard.RegisterApplyStyle (cell00, _createUserWizard.TitleTextStyle);
- row0.Cells.Add (cell00);
- // Row #1
- TableRow row1 = new TableRow ();
- TableCell cell10 = new TableCell ();
- cell10.HorizontalAlign = HorizontalAlign.Center;
- _createUserWizard.RegisterApplyStyle (cell10, _createUserWizard.CompleteSuccessTextStyle);
- row1.Cells.Add (cell10);
- // Row #2
- TableRow row2 = new TableRow ();
- TableCell cell20 = new TableCell ();
- cell20.HorizontalAlign = HorizontalAlign.Right;
- cell20.ColumnSpan = 2;
- row2.Cells.Add (cell20);
- Control[] b = _createUserWizard.CreateButtonSet ("ContinueButton", CreateUserWizard.ContinueButtonCommandName);
- for (int i = 0; i < b.Length; i++)
- cell20.Controls.Add (b [i]);
- // Row #3
- TableRow row3 = new TableRow ();
- TableCell cell30 = new TableCell ();
- cell30.Controls.Add (new Image ());
- HyperLink link = new HyperLink ();
- link.ID = "EditProfileLink";
- _createUserWizard.RegisterApplyStyle (link, _createUserWizard.HyperLinkStyle);
- cell30.Controls.Add (link);
- row3.Cells.Add (cell30);
- // table
- table.Rows.Add (row0);
- table.Rows.Add (row1);
- table.Rows.Add (row2);
- table.Rows.Add (row3);
- container.Controls.Add (table);
- }
- #endregion
- }
- }
- }
- #endif
|