2
0

CreateUserWizard.cs 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347
  1. //
  2. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  3. //
  4. // Authors:
  5. // Vladimir Krasnov <[email protected]>
  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. #if NET_2_0
  27. using System;
  28. using System.Web;
  29. using System.Web.UI;
  30. using System.Web.Security;
  31. using System.Collections;
  32. using System.Collections.Specialized;
  33. using System.ComponentModel;
  34. using System.Text;
  35. using System.Net.Mail;
  36. namespace System.Web.UI.WebControls
  37. {
  38. [BindableAttribute (false)]
  39. public class CreateUserWizard : Wizard
  40. {
  41. public static readonly string ContinueButtonCommandName = "Continue";
  42. private string _password = "";
  43. private string _confirmPassword = "";
  44. private MembershipProvider _provider = null;
  45. private ITextControl _errorMessageLabel = null;
  46. private MailDefinition _mailDefinition = null;
  47. private Style _textBoxStyle = null;
  48. private Style _validatorTextStyle = null;
  49. private TableItemStyle _completeSuccessTextStyle = null;
  50. private TableItemStyle _errorMessageStyle = null;
  51. private TableItemStyle _hyperLinkStyle = null;
  52. private TableItemStyle _instructionTextStyle = null;
  53. private TableItemStyle _labelStyle = null;
  54. private TableItemStyle _passwordHintStyle = null;
  55. private TableItemStyle _titleTextStyle = null;
  56. Style _createUserButtonStyle;
  57. Style _continueButtonStyle;
  58. private static readonly object CreatedUserEvent = new object ();
  59. private static readonly object CreateUserErrorEvent = new object ();
  60. private static readonly object CreatingUserEvent = new object ();
  61. private static readonly object ContinueButtonClickEvent = new object ();
  62. private static readonly object SendingMailEvent = new object ();
  63. private static readonly object SendMailErrorEvent = new object ();
  64. private CompleteWizardStep _completeWizardStep = null;
  65. private CreateUserWizardStep _createUserWizardStep = null;
  66. public CreateUserWizard ()
  67. {
  68. }
  69. #region Public Properties
  70. public override int ActiveStepIndex
  71. {
  72. get { return base.ActiveStepIndex; }
  73. set { base.ActiveStepIndex = value; }
  74. }
  75. [LocalizableAttribute (true)]
  76. [ThemeableAttribute (false)]
  77. public virtual string Answer
  78. {
  79. get
  80. {
  81. object o = ViewState ["Answer"];
  82. return (o == null) ? String.Empty : (string) o;
  83. }
  84. set
  85. {
  86. if (value == null)
  87. ViewState.Remove ("Answer");
  88. else
  89. ViewState ["Answer"] = value;
  90. }
  91. }
  92. [LocalizableAttribute (true)]
  93. public virtual string AnswerLabelText
  94. {
  95. get
  96. {
  97. object o = ViewState ["AnswerLabelText"];
  98. return (o == null) ? Locale.GetText ("Security Answer:") : (string) o;
  99. }
  100. set
  101. {
  102. if (value == null)
  103. ViewState.Remove ("AnswerLabelText");
  104. else
  105. ViewState ["AnswerLabelText"] = value;
  106. }
  107. }
  108. [LocalizableAttribute (true)]
  109. public virtual string AnswerRequiredErrorMessage
  110. {
  111. get
  112. {
  113. object o = ViewState ["AnswerRequiredErrorMessage"];
  114. return (o == null) ? Locale.GetText ("Security answer is required.") : (string) o;
  115. }
  116. set
  117. {
  118. if (value == null)
  119. ViewState.Remove ("AnswerRequiredErrorMessage");
  120. else
  121. ViewState ["AnswerRequiredErrorMessage"] = value;
  122. }
  123. }
  124. [ThemeableAttribute (false)]
  125. public virtual bool AutoGeneratePassword
  126. {
  127. get
  128. {
  129. object o = ViewState ["AutoGeneratePassword"];
  130. return (o == null) ? false : (bool) o;
  131. }
  132. set
  133. {
  134. ViewState ["AutoGeneratePassword"] = value;
  135. }
  136. }
  137. public CompleteWizardStep CompleteStep
  138. {
  139. get
  140. {
  141. if (_completeWizardStep == null) {
  142. for (int i = 0; i < WizardSteps.Count; i++)
  143. if (WizardSteps [i] is CompleteWizardStep) {
  144. _completeWizardStep = (CompleteWizardStep) WizardSteps [i];
  145. if (_completeWizardStep.Wizard == null)
  146. _completeWizardStep.SetWizard (this);
  147. }
  148. }
  149. return _completeWizardStep;
  150. }
  151. }
  152. [LocalizableAttribute (true)]
  153. public virtual string CompleteSuccessText
  154. {
  155. get
  156. {
  157. object o = ViewState ["CompleteSuccessText"];
  158. return (o == null) ? Locale.GetText ("Your account has been successfully created.") : (string) o;
  159. }
  160. set
  161. {
  162. if (value == null)
  163. ViewState.Remove ("CompleteSuccessText");
  164. else
  165. ViewState ["CompleteSuccessText"] = value;
  166. }
  167. }
  168. public TableItemStyle CompleteSuccessTextStyle
  169. {
  170. get
  171. {
  172. if (_completeSuccessTextStyle == null) {
  173. _completeSuccessTextStyle = new TableItemStyle ();
  174. if (IsTrackingViewState)
  175. ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
  176. }
  177. return _completeSuccessTextStyle;
  178. }
  179. }
  180. public virtual string ConfirmPassword
  181. {
  182. get { return _confirmPassword; }
  183. }
  184. [LocalizableAttribute (true)]
  185. public virtual string ConfirmPasswordCompareErrorMessage
  186. {
  187. get
  188. {
  189. object o = ViewState ["ConfirmPasswordCompareErrorMessage"];
  190. return (o == null) ? Locale.GetText ("The Password and Confirmation Password must match.") : (string) o;
  191. }
  192. set
  193. {
  194. if (value == null)
  195. ViewState.Remove ("ConfirmPasswordCompareErrorMessage");
  196. else
  197. ViewState ["ConfirmPasswordCompareErrorMessage"] = value;
  198. }
  199. }
  200. [LocalizableAttribute (true)]
  201. public virtual string ConfirmPasswordLabelText
  202. {
  203. get
  204. {
  205. object o = ViewState ["ConfirmPasswordLabelText"];
  206. return (o == null) ? Locale.GetText ("Confirm Password:") : (string) o;
  207. }
  208. set
  209. {
  210. if (value == null)
  211. ViewState.Remove ("ConfirmPasswordLabelText");
  212. else
  213. ViewState ["ConfirmPasswordLabelText"] = value;
  214. }
  215. }
  216. [LocalizableAttribute (true)]
  217. public virtual string ConfirmPasswordRequiredErrorMessage
  218. {
  219. get
  220. {
  221. object o = ViewState ["ConfirmPasswordRequiredErrorMessage"];
  222. return (o == null) ? Locale.GetText ("Confirm Password is required.") : (string) o;
  223. }
  224. set
  225. {
  226. if (value == null)
  227. ViewState.Remove ("ConfirmPasswordRequiredErrorMessage");
  228. else
  229. ViewState ["ConfirmPasswordRequiredErrorMessage"] = value;
  230. }
  231. }
  232. public virtual string ContinueButtonImageUrl
  233. {
  234. get { return ViewState.GetString ("ContinueButtonImageUrl", String.Empty); }
  235. set { ViewState ["ContinueButtonImageUrl"] = value; }
  236. }
  237. public Style ContinueButtonStyle
  238. {
  239. get {
  240. if (_continueButtonStyle == null) {
  241. _continueButtonStyle = new Style ();
  242. if (IsTrackingViewState)
  243. ((IStateManager) _continueButtonStyle).TrackViewState ();
  244. }
  245. return _continueButtonStyle;
  246. }
  247. }
  248. [LocalizableAttribute (true)]
  249. public virtual string ContinueButtonText
  250. {
  251. get { return ViewState.GetString ("ContinueButtonText", "Continue"); }
  252. set { ViewState ["ContinueButtonText"] = value; }
  253. }
  254. public virtual ButtonType ContinueButtonType
  255. {
  256. get {
  257. object v = ViewState ["ContinueButtonType"];
  258. return v != null ? (ButtonType) v : ButtonType.Button;
  259. }
  260. set {
  261. ViewState ["ContinueButtonType"] = value;
  262. }
  263. }
  264. [ThemeableAttribute (false)]
  265. public virtual string ContinueDestinationPageUrl
  266. {
  267. get
  268. {
  269. object o = ViewState ["ContinueDestinationPageUrl"];
  270. return (o == null) ? "" : (string) o;
  271. }
  272. set
  273. {
  274. if (value == null)
  275. ViewState.Remove ("ContinueDestinationPageUrl");
  276. else
  277. ViewState ["ContinueDestinationPageUrl"] = value;
  278. }
  279. }
  280. public virtual string CreateUserButtonImageUrl
  281. {
  282. get { return ViewState.GetString ("CreateUserButtonImageUrl", String.Empty); }
  283. set { ViewState ["CreateUserButtonImageUrl"] = value; }
  284. }
  285. public Style CreateUserButtonStyle
  286. {
  287. get {
  288. if (_createUserButtonStyle == null) {
  289. _createUserButtonStyle = new Style ();
  290. if (IsTrackingViewState)
  291. ((IStateManager) _createUserButtonStyle).TrackViewState ();
  292. }
  293. return _createUserButtonStyle;
  294. }
  295. }
  296. [LocalizableAttribute (true)]
  297. public virtual string CreateUserButtonText
  298. {
  299. get { return ViewState.GetString ("CreateUserButtonText", "Create User"); }
  300. set { ViewState ["CreateUserButtonText"] = value; }
  301. }
  302. public virtual ButtonType CreateUserButtonType
  303. {
  304. get {
  305. object v = ViewState ["CreateUserButtonType"];
  306. return v != null ? (ButtonType) v : ButtonType.Button;
  307. }
  308. set {
  309. ViewState ["CreateUserButtonType"] = value;
  310. }
  311. }
  312. public CreateUserWizardStep CreateUserStep
  313. {
  314. get
  315. {
  316. if (_createUserWizardStep == null) {
  317. for (int i = 0; i < WizardSteps.Count; i++)
  318. if (WizardSteps [i] is CreateUserWizardStep) {
  319. _createUserWizardStep = (CreateUserWizardStep) WizardSteps [i];
  320. if (_createUserWizardStep.Wizard == null)
  321. _createUserWizardStep.SetWizard (this);
  322. }
  323. }
  324. return _createUserWizardStep;
  325. }
  326. }
  327. [ThemeableAttribute (false)]
  328. public virtual bool DisableCreatedUser
  329. {
  330. get
  331. {
  332. object o = ViewState ["DisableCreatedUser"];
  333. return (o == null) ? false : (bool) o;
  334. }
  335. set
  336. {
  337. ViewState ["DisableCreatedUser"] = value;
  338. }
  339. }
  340. public override bool DisplaySideBar
  341. {
  342. get {
  343. return ViewState.GetBool ("DisplaySideBar", false);
  344. }
  345. set {
  346. ViewState ["DisplaySideBar"] = value;
  347. ChildControlsCreated = false;
  348. }
  349. }
  350. [LocalizableAttribute (true)]
  351. public virtual string DuplicateEmailErrorMessage
  352. {
  353. get
  354. {
  355. object o = ViewState ["DuplicateEmailErrorMessage"];
  356. 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;
  357. }
  358. set
  359. {
  360. if (value == null)
  361. ViewState.Remove ("DuplicateEmailErrorMessage");
  362. else
  363. ViewState ["DuplicateEmailErrorMessage"] = value;
  364. }
  365. }
  366. [LocalizableAttribute (true)]
  367. public virtual string DuplicateUserNameErrorMessage
  368. {
  369. get
  370. {
  371. object o = ViewState ["DuplicateUserNameErrorMessage"];
  372. return (o == null) ? Locale.GetText ("Please enter a different user name.") : (string) o;
  373. }
  374. set
  375. {
  376. if (value == null)
  377. ViewState.Remove ("DuplicateUserNameErrorMessage");
  378. else
  379. ViewState ["DuplicateUserNameErrorMessage"] = value;
  380. }
  381. }
  382. public virtual string EditProfileIconUrl
  383. {
  384. get
  385. {
  386. object o = ViewState ["EditProfileIconUrl"];
  387. return (o == null) ? "" : (string) o;
  388. }
  389. set
  390. {
  391. if (value == null)
  392. ViewState.Remove ("EditProfileIconUrl");
  393. else
  394. ViewState ["EditProfileIconUrl"] = value;
  395. }
  396. }
  397. [LocalizableAttribute (true)]
  398. public virtual string EditProfileText
  399. {
  400. get
  401. {
  402. object o = ViewState ["EditProfileText"];
  403. return (o == null) ? "" : (string) o;
  404. }
  405. set
  406. {
  407. if (value == null)
  408. ViewState.Remove ("EditProfileText");
  409. else
  410. ViewState ["EditProfileText"] = value;
  411. }
  412. }
  413. public virtual string EditProfileUrl
  414. {
  415. get
  416. {
  417. object o = ViewState ["EditProfileUrl"];
  418. return (o == null) ? "" : (string) o;
  419. }
  420. set
  421. {
  422. if (value == null)
  423. ViewState.Remove ("EditProfileUrl");
  424. else
  425. ViewState ["EditProfileUrl"] = value;
  426. }
  427. }
  428. public virtual string Email
  429. {
  430. get
  431. {
  432. object o = ViewState ["Email"];
  433. return (o == null) ? String.Empty : (string) o;
  434. }
  435. set
  436. {
  437. if (value == null)
  438. ViewState.Remove ("Email");
  439. else
  440. ViewState ["Email"] = value;
  441. }
  442. }
  443. [LocalizableAttribute (true)]
  444. public virtual string EmailLabelText
  445. {
  446. get
  447. {
  448. object o = ViewState ["EmailLabelText"];
  449. return (o == null) ? Locale.GetText ("E-mail:") : (string) o;
  450. }
  451. set
  452. {
  453. if (value == null)
  454. ViewState.Remove ("EmailLabelText");
  455. else
  456. ViewState ["EmailLabelText"] = value;
  457. }
  458. }
  459. public virtual string EmailRegularExpression
  460. {
  461. get
  462. {
  463. object o = ViewState ["EmailRegularExpression"];
  464. return (o == null) ? "" : (string) o;
  465. }
  466. set
  467. {
  468. if (value == null)
  469. ViewState.Remove ("EmailRegularExpression");
  470. else
  471. ViewState ["EmailRegularExpression"] = value;
  472. }
  473. }
  474. public virtual string EmailRegularExpressionErrorMessage
  475. {
  476. get
  477. {
  478. object o = ViewState ["EmailRegularExpressionErrorMessage"];
  479. return (o == null) ? Locale.GetText ("Please enter a different e-mail.") : (string) o;
  480. }
  481. set
  482. {
  483. if (value == null)
  484. ViewState.Remove ("EmailRegularExpressionErrorMessage");
  485. else
  486. ViewState ["EmailRegularExpressionErrorMessage"] = value;
  487. }
  488. }
  489. [LocalizableAttribute (true)]
  490. public virtual string EmailRequiredErrorMessage
  491. {
  492. get
  493. {
  494. object o = ViewState ["EmailRequiredErrorMessage"];
  495. return (o == null) ? Locale.GetText ("E-mail is required.") : (string) o;
  496. }
  497. set
  498. {
  499. if (value == null)
  500. ViewState.Remove ("EmailRequiredErrorMessage");
  501. else
  502. ViewState ["EmailRequiredErrorMessage"] = value;
  503. }
  504. }
  505. public TableItemStyle ErrorMessageStyle
  506. {
  507. get
  508. {
  509. if (_errorMessageStyle == null) {
  510. _errorMessageStyle = new TableItemStyle ();
  511. if (IsTrackingViewState)
  512. ((IStateManager) _errorMessageStyle).TrackViewState ();
  513. }
  514. return _errorMessageStyle;
  515. }
  516. }
  517. public virtual string HelpPageIconUrl
  518. {
  519. get
  520. {
  521. object o = ViewState ["HelpPageIconUrl"];
  522. return (o == null) ? "" : (string) o;
  523. }
  524. set
  525. {
  526. if (value == null)
  527. ViewState.Remove ("HelpPageIconUrl");
  528. else
  529. ViewState ["HelpPageIconUrl"] = value;
  530. }
  531. }
  532. [LocalizableAttribute (true)]
  533. public virtual string HelpPageText
  534. {
  535. get
  536. {
  537. object o = ViewState ["HelpPageText"];
  538. return (o == null) ? "" : (string) o;
  539. }
  540. set
  541. {
  542. if (value == null)
  543. ViewState.Remove ("HelpPageText");
  544. else
  545. ViewState ["HelpPageText"] = value;
  546. }
  547. }
  548. public virtual string HelpPageUrl
  549. {
  550. get
  551. {
  552. object o = ViewState ["HelpPageUrl"];
  553. return (o == null) ? "" : (string) o;
  554. }
  555. set
  556. {
  557. if (value == null)
  558. ViewState.Remove ("HelpPageUrl");
  559. else
  560. ViewState ["HelpPageUrl"] = value;
  561. }
  562. }
  563. public TableItemStyle HyperLinkStyle
  564. {
  565. get
  566. {
  567. if (_hyperLinkStyle == null) {
  568. _hyperLinkStyle = new TableItemStyle ();
  569. if (IsTrackingViewState)
  570. ((IStateManager) _hyperLinkStyle).TrackViewState ();
  571. }
  572. return _hyperLinkStyle;
  573. }
  574. }
  575. [LocalizableAttribute (true)]
  576. public virtual string InstructionText
  577. {
  578. get
  579. {
  580. object o = ViewState ["InstructionText"];
  581. return (o == null) ? "" : (string) o;
  582. }
  583. set
  584. {
  585. if (value == null)
  586. ViewState.Remove ("InstructionText");
  587. else
  588. ViewState ["InstructionText"] = value;
  589. }
  590. }
  591. public TableItemStyle InstructionTextStyle
  592. {
  593. get
  594. {
  595. if (_instructionTextStyle == null) {
  596. _instructionTextStyle = new TableItemStyle ();
  597. if (IsTrackingViewState)
  598. ((IStateManager) _instructionTextStyle).TrackViewState ();
  599. }
  600. return _instructionTextStyle;
  601. }
  602. }
  603. [LocalizableAttribute (true)]
  604. public virtual string InvalidAnswerErrorMessage
  605. {
  606. get
  607. {
  608. object o = ViewState ["InvalidAnswerErrorMessage"];
  609. return (o == null) ? Locale.GetText ("Please enter a different security answer.") : (string) o;
  610. }
  611. set
  612. {
  613. if (value == null)
  614. ViewState.Remove ("InvalidAnswerErrorMessage");
  615. else
  616. ViewState ["InvalidAnswerErrorMessage"] = value;
  617. }
  618. }
  619. [LocalizableAttribute (true)]
  620. public virtual string InvalidEmailErrorMessage
  621. {
  622. get
  623. {
  624. object o = ViewState ["InvalidEmailErrorMessage"];
  625. return (o == null) ? Locale.GetText ("Please enter a valid e-mail address.") : (string) o;
  626. }
  627. set
  628. {
  629. if (value == null)
  630. ViewState.Remove ("InvalidEmailErrorMessage");
  631. else
  632. ViewState ["InvalidEmailErrorMessage"] = value;
  633. }
  634. }
  635. [MonoTODO ("take the values from membership provider")]
  636. [LocalizableAttribute (true)]
  637. public virtual string InvalidPasswordErrorMessage
  638. {
  639. get
  640. {
  641. object o = ViewState ["InvalidPasswordErrorMessage"];
  642. return (o == null) ? Locale.GetText ("Password length minimum: {0}. Non-alphanumeric characters required: {1}.") : (string) o;
  643. }
  644. set
  645. {
  646. if (value == null)
  647. ViewState.Remove ("InvalidPasswordErrorMessage");
  648. else
  649. ViewState ["InvalidPasswordErrorMessage"] = value;
  650. }
  651. }
  652. [LocalizableAttribute (true)]
  653. public virtual string InvalidQuestionErrorMessage
  654. {
  655. get
  656. {
  657. object o = ViewState ["InvalidQuestionErrorMessage"];
  658. return (o == null) ? Locale.GetText ("Please enter a different security question.") : (string) o;
  659. }
  660. set
  661. {
  662. if (value == null)
  663. ViewState.Remove ("InvalidQuestionErrorMessage");
  664. else
  665. ViewState ["InvalidQuestionErrorMessage"] = value;
  666. }
  667. }
  668. public TableItemStyle LabelStyle
  669. {
  670. get
  671. {
  672. if (_labelStyle == null) {
  673. _labelStyle = new TableItemStyle ();
  674. if (IsTrackingViewState)
  675. ((IStateManager) _labelStyle).TrackViewState ();
  676. }
  677. return _labelStyle;
  678. }
  679. }
  680. [ThemeableAttribute (false)]
  681. public virtual bool LoginCreatedUser
  682. {
  683. get
  684. {
  685. object o = ViewState ["LoginCreatedUser"];
  686. return (o == null) ? true : (bool) o;
  687. }
  688. set
  689. {
  690. ViewState ["LoginCreatedUser"] = value;
  691. }
  692. }
  693. [ThemeableAttribute (false)]
  694. public MailDefinition MailDefinition {
  695. get {
  696. if (this._mailDefinition == null) {
  697. this._mailDefinition = new MailDefinition();
  698. if (IsTrackingViewState)
  699. ((IStateManager) _mailDefinition).TrackViewState ();
  700. }
  701. return _mailDefinition;
  702. }
  703. }
  704. [ThemeableAttribute (false)]
  705. public virtual string MembershipProvider
  706. {
  707. get
  708. {
  709. object o = ViewState ["MembershipProvider"];
  710. return (o == null) ? "" : (string) o;
  711. }
  712. set
  713. {
  714. if (value == null)
  715. ViewState.Remove ("MembershipProvider");
  716. else
  717. ViewState ["MembershipProvider"] = value;
  718. _provider = null;
  719. }
  720. }
  721. internal virtual MembershipProvider MembershipProviderInternal
  722. {
  723. get
  724. {
  725. if (_provider == null)
  726. InitMemberShipProvider ();
  727. return _provider;
  728. }
  729. }
  730. public virtual string Password
  731. {
  732. get { return _password; }
  733. }
  734. public TableItemStyle PasswordHintStyle
  735. {
  736. get
  737. {
  738. if (_passwordHintStyle == null) {
  739. _passwordHintStyle = new TableItemStyle ();
  740. if (IsTrackingViewState)
  741. ((IStateManager) _passwordHintStyle).TrackViewState ();
  742. }
  743. return _passwordHintStyle;
  744. }
  745. }
  746. [LocalizableAttribute (true)]
  747. public virtual string PasswordHintText
  748. {
  749. get
  750. {
  751. object o = ViewState ["PasswordHintText"];
  752. return (o == null) ? "" : (string) o;
  753. }
  754. set
  755. {
  756. if (value == null)
  757. ViewState.Remove ("PasswordHintText");
  758. else
  759. ViewState ["PasswordHintText"] = value;
  760. }
  761. }
  762. [LocalizableAttribute (true)]
  763. public virtual string PasswordLabelText
  764. {
  765. get
  766. {
  767. object o = ViewState ["PasswordLabelText"];
  768. return (o == null) ? Locale.GetText ("Password:") : (string) o;
  769. }
  770. set
  771. {
  772. if (value == null)
  773. ViewState.Remove ("PasswordLabelText");
  774. else
  775. ViewState ["PasswordLabelText"] = value;
  776. }
  777. }
  778. public virtual string PasswordRegularExpression
  779. {
  780. get
  781. {
  782. object o = ViewState ["PasswordRegularExpression"];
  783. return (o == null) ? "" : (string) o;
  784. }
  785. set
  786. {
  787. if (value == null)
  788. ViewState.Remove ("PasswordRegularExpression");
  789. else
  790. ViewState ["PasswordRegularExpression"] = value;
  791. }
  792. }
  793. public virtual string PasswordRegularExpressionErrorMessage
  794. {
  795. get
  796. {
  797. object o = ViewState ["PasswordRegularExpressionErrorMessage"];
  798. return (o == null) ? Locale.GetText ("Please enter a different password.") : (string) o;
  799. }
  800. set
  801. {
  802. if (value == null)
  803. ViewState.Remove ("PasswordRegularExpressionErrorMessage");
  804. else
  805. ViewState ["PasswordRegularExpressionErrorMessage"] = value;
  806. }
  807. }
  808. [LocalizableAttribute (true)]
  809. public virtual string PasswordRequiredErrorMessage
  810. {
  811. get
  812. {
  813. object o = ViewState ["PasswordRequiredErrorMessage"];
  814. return (o == null) ? Locale.GetText ("Password is required.") : (string) o;
  815. }
  816. set
  817. {
  818. if (value == null)
  819. ViewState.Remove ("PasswordRequiredErrorMessage");
  820. else
  821. ViewState ["PasswordRequiredErrorMessage"] = value;
  822. }
  823. }
  824. [LocalizableAttribute (true)]
  825. [ThemeableAttribute (false)]
  826. public virtual string Question
  827. {
  828. get
  829. {
  830. object o = ViewState ["Question"];
  831. return (o == null) ? String.Empty : (string) o;
  832. }
  833. set
  834. {
  835. if (value == null)
  836. ViewState.Remove ("Question");
  837. else
  838. ViewState ["Question"] = value;
  839. }
  840. }
  841. [LocalizableAttribute (true)]
  842. public virtual string QuestionLabelText
  843. {
  844. get
  845. {
  846. object o = ViewState ["QuestionLabelText"];
  847. return (o == null) ? Locale.GetText ("Security Question:") : (string) o;
  848. }
  849. set
  850. {
  851. if (value == null)
  852. ViewState.Remove ("QuestionLabelText");
  853. else
  854. ViewState ["QuestionLabelText"] = value;
  855. }
  856. }
  857. [LocalizableAttribute (true)]
  858. public virtual string QuestionRequiredErrorMessage
  859. {
  860. get
  861. {
  862. object o = ViewState ["QuestionRequiredErrorMessage"];
  863. return (o == null) ? Locale.GetText ("Security question is required.") : (string) o;
  864. }
  865. set
  866. {
  867. if (value == null)
  868. ViewState.Remove ("QuestionRequiredErrorMessage");
  869. else
  870. ViewState ["QuestionRequiredErrorMessage"] = value;
  871. }
  872. }
  873. [ThemeableAttribute (false)]
  874. public virtual bool RequireEmail
  875. {
  876. get
  877. {
  878. object o = ViewState ["RequireEmail"];
  879. return (o == null) ? true : (bool) o;
  880. }
  881. set
  882. {
  883. ViewState ["RequireEmail"] = value;
  884. }
  885. }
  886. [MonoTODO ("doesnt work")]
  887. public override string SkipLinkText
  888. {
  889. get
  890. {
  891. object o = ViewState ["SkipLinkText"];
  892. return (o == null) ? "" : (string) o;
  893. }
  894. set
  895. {
  896. if (value == null)
  897. ViewState.Remove ("SkipLinkText");
  898. else
  899. ViewState ["SkipLinkText"] = value;
  900. }
  901. }
  902. public Style TextBoxStyle
  903. {
  904. get
  905. {
  906. if (_textBoxStyle == null) {
  907. _textBoxStyle = new Style ();
  908. if (IsTrackingViewState)
  909. ((IStateManager) _textBoxStyle).TrackViewState ();
  910. }
  911. return _textBoxStyle;
  912. }
  913. }
  914. public TableItemStyle TitleTextStyle
  915. {
  916. get
  917. {
  918. if (_titleTextStyle == null) {
  919. _titleTextStyle = new TableItemStyle ();
  920. if (IsTrackingViewState)
  921. ((IStateManager) _titleTextStyle).TrackViewState ();
  922. }
  923. return _titleTextStyle;
  924. }
  925. }
  926. [LocalizableAttribute (true)]
  927. public virtual string UnknownErrorMessage
  928. {
  929. get
  930. {
  931. object o = ViewState ["UnknownErrorMessage"];
  932. return (o == null) ? Locale.GetText ("Your account was not created. Please try again.") : (string) o;
  933. }
  934. set
  935. {
  936. if (value == null)
  937. ViewState.Remove ("UnknownErrorMessage");
  938. else
  939. ViewState ["UnknownErrorMessage"] = value;
  940. }
  941. }
  942. public virtual string UserName
  943. {
  944. get
  945. {
  946. object o = ViewState ["UserName"];
  947. return (o == null) ? String.Empty : (string) o;
  948. }
  949. set
  950. {
  951. if (value == null)
  952. ViewState.Remove ("UserName");
  953. else
  954. ViewState ["UserName"] = value;
  955. }
  956. }
  957. [LocalizableAttribute (true)]
  958. public virtual string UserNameLabelText
  959. {
  960. get
  961. {
  962. object o = ViewState ["UserNameLabelText"];
  963. return (o == null) ? Locale.GetText ("User Name:") : (string) o;
  964. }
  965. set
  966. {
  967. if (value == null)
  968. ViewState.Remove ("UserNameLabelText");
  969. else
  970. ViewState ["UserNameLabelText"] = value;
  971. }
  972. }
  973. [LocalizableAttribute (true)]
  974. public virtual string UserNameRequiredErrorMessage
  975. {
  976. get
  977. {
  978. object o = ViewState ["UserNameRequiredErrorMessage"];
  979. return (o == null) ? Locale.GetText ("User Name is required.") : (string) o;
  980. }
  981. set
  982. {
  983. if (value == null)
  984. ViewState.Remove ("UserNameRequiredErrorMessage");
  985. else
  986. ViewState ["UserNameRequiredErrorMessage"] = value;
  987. }
  988. }
  989. public Style ValidatorTextStyle
  990. {
  991. get
  992. {
  993. if (_validatorTextStyle == null) {
  994. _validatorTextStyle = new Style ();
  995. if (IsTrackingViewState)
  996. ((IStateManager) _validatorTextStyle).TrackViewState ();
  997. }
  998. return _validatorTextStyle;
  999. }
  1000. }
  1001. [ThemeableAttribute (false)]
  1002. public override WizardStepCollection WizardSteps
  1003. {
  1004. get { return base.WizardSteps; }
  1005. }
  1006. #endregion
  1007. #region Protected Properties
  1008. protected internal bool QuestionAndAnswerRequired
  1009. {
  1010. get { return MembershipProviderInternal.RequiresQuestionAndAnswer; }
  1011. }
  1012. public event EventHandler ContinueButtonClick
  1013. {
  1014. add { Events.AddHandler (ContinueButtonClickEvent, value); }
  1015. remove { Events.RemoveHandler (ContinueButtonClickEvent, value); }
  1016. }
  1017. public event EventHandler CreatedUser
  1018. {
  1019. add { Events.AddHandler (CreatedUserEvent, value); }
  1020. remove { Events.RemoveHandler (CreatedUserEvent, value); }
  1021. }
  1022. public event CreateUserErrorEventHandler CreateUserError
  1023. {
  1024. add { Events.AddHandler (CreateUserErrorEvent, value); }
  1025. remove { Events.RemoveHandler (CreateUserErrorEvent, value); }
  1026. }
  1027. public event LoginCancelEventHandler CreatingUser
  1028. {
  1029. add { Events.AddHandler (CreatingUserEvent, value); }
  1030. remove { Events.RemoveHandler (CreatingUserEvent, value); }
  1031. }
  1032. public event MailMessageEventHandler SendingMail
  1033. {
  1034. add { Events.AddHandler (SendingMailEvent, value); }
  1035. remove { Events.RemoveHandler (SendingMailEvent, value); }
  1036. }
  1037. public event SendMailErrorEventHandler SendMailError
  1038. {
  1039. add { Events.AddHandler (SendMailErrorEvent, value); }
  1040. remove { Events.RemoveHandler (SendMailErrorEvent, value); }
  1041. }
  1042. #endregion
  1043. #region Internal Properties
  1044. internal override void InstantiateTemplateStep (TemplatedWizardStep step)
  1045. {
  1046. if (step is CreateUserWizardStep) {
  1047. InstantiateCreateUserWizardStep ((CreateUserWizardStep) step);
  1048. }
  1049. else if (step is CompleteWizardStep) {
  1050. InstantiateCompleteWizardStep ((CompleteWizardStep) step);
  1051. }
  1052. else {
  1053. base.InstantiateTemplateStep (step);
  1054. }
  1055. }
  1056. private void InstantiateCompleteWizardStep (CompleteWizardStep step)
  1057. {
  1058. CompleteStepContainer contentTemplateContainer = new CompleteStepContainer (this);
  1059. if (step.ContentTemplate != null) {
  1060. step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
  1061. }
  1062. else {
  1063. new CompleteStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
  1064. contentTemplateContainer.ConfirmDefaultTemplate ();
  1065. }
  1066. step.ContentTemplateContainer = contentTemplateContainer;
  1067. step.Controls.Clear ();
  1068. step.Controls.Add (contentTemplateContainer);
  1069. BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
  1070. if (step.CustomNavigationTemplate != null) {
  1071. step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
  1072. RegisterCustomNavigation (step, customNavigationTemplateContainer);
  1073. }
  1074. step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
  1075. }
  1076. void InstantiateCreateUserWizardStep (CreateUserWizardStep step)
  1077. {
  1078. CreateUserStepContainer contentTemplateContainer = new CreateUserStepContainer (this);
  1079. if (step.ContentTemplate != null) {
  1080. step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
  1081. }
  1082. else {
  1083. new CreateUserStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
  1084. contentTemplateContainer.ConfirmDefaultTemplate ();
  1085. contentTemplateContainer.EnsureValidatorsState ();
  1086. }
  1087. step.ContentTemplateContainer = contentTemplateContainer;
  1088. step.Controls.Clear ();
  1089. step.Controls.Add (contentTemplateContainer);
  1090. CreateUserNavigationContainer customNavigationTemplateContainer = new CreateUserNavigationContainer (this);
  1091. if (step.CustomNavigationTemplate != null) {
  1092. step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
  1093. }
  1094. else {
  1095. new CreateUserStepNavigationTemplate (this).InstantiateIn (customNavigationTemplateContainer);
  1096. customNavigationTemplateContainer.ConfirmDefaultTemplate ();
  1097. }
  1098. RegisterCustomNavigation (step, customNavigationTemplateContainer);
  1099. step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
  1100. }
  1101. internal override ITemplate SideBarItemTemplate
  1102. {
  1103. get { return new SideBarLabelTemplate (this); }
  1104. }
  1105. #endregion
  1106. #region Protected Methods
  1107. protected internal override void CreateChildControls ()
  1108. {
  1109. if (CreateUserStep == null)
  1110. WizardSteps.AddAt (0, new CreateUserWizardStep ());
  1111. if (CompleteStep == null)
  1112. WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
  1113. base.CreateChildControls ();
  1114. }
  1115. protected override void CreateControlHierarchy ()
  1116. {
  1117. base.CreateControlHierarchy ();
  1118. CreateUserStepContainer container = CreateUserStep.ContentTemplateContainer as CreateUserStepContainer;
  1119. if (container != null) {
  1120. IEditableTextControl editable;
  1121. editable = container.UserNameTextBox as IEditableTextControl;
  1122. if (editable != null)
  1123. editable.TextChanged += new EventHandler (UserName_TextChanged);
  1124. if (!AutoGeneratePassword) {
  1125. editable = container.PasswordTextBox as IEditableTextControl;
  1126. if (editable != null)
  1127. editable.TextChanged += new EventHandler (Password_TextChanged);
  1128. editable = container.ConfirmPasswordTextBox as IEditableTextControl;
  1129. if (editable != null)
  1130. editable.TextChanged += new EventHandler (ConfirmPassword_TextChanged);
  1131. }
  1132. if (RequireEmail) {
  1133. editable = container.EmailTextBox as IEditableTextControl;
  1134. if (editable != null)
  1135. editable.TextChanged += new EventHandler (Email_TextChanged);
  1136. }
  1137. if (QuestionAndAnswerRequired) {
  1138. editable = container.QuestionTextBox as IEditableTextControl;
  1139. if (editable != null)
  1140. editable.TextChanged += new EventHandler (Question_TextChanged);
  1141. editable = container.AnswerTextBox as IEditableTextControl;
  1142. if (editable != null)
  1143. editable.TextChanged += new EventHandler (Answer_TextChanged);
  1144. }
  1145. _errorMessageLabel = container.ErrorMessageLabel;
  1146. }
  1147. }
  1148. [MonoTODO ("Not Implemented")]
  1149. protected override IDictionary GetDesignModeState ()
  1150. {
  1151. throw new NotImplementedException ();
  1152. }
  1153. protected override bool OnBubbleEvent (object source, EventArgs e)
  1154. {
  1155. CommandEventArgs args = e as CommandEventArgs;
  1156. if (e != null && args.CommandName == ContinueButtonCommandName) {
  1157. ProcessContinueEvent ();
  1158. return true;
  1159. }
  1160. return base.OnBubbleEvent (source, e);
  1161. }
  1162. private void ProcessContinueEvent () {
  1163. OnContinueButtonClick (EventArgs.Empty);
  1164. if (ContinueDestinationPageUrl.Length > 0) {
  1165. Context.Response.Redirect (ContinueDestinationPageUrl);
  1166. }
  1167. }
  1168. protected virtual void OnContinueButtonClick (EventArgs e)
  1169. {
  1170. if (Events != null) {
  1171. EventHandler eh = (EventHandler) Events [ContinueButtonClickEvent];
  1172. if (eh != null) eh (this, e);
  1173. }
  1174. }
  1175. protected virtual void OnCreatedUser (EventArgs e)
  1176. {
  1177. if (Events != null) {
  1178. EventHandler eh = (EventHandler) Events [CreatedUserEvent];
  1179. if (eh != null) eh (this, e);
  1180. }
  1181. }
  1182. protected virtual void OnCreateUserError (CreateUserErrorEventArgs e)
  1183. {
  1184. if (Events != null) {
  1185. CreateUserErrorEventHandler eh = (CreateUserErrorEventHandler) Events [CreateUserErrorEvent];
  1186. if (eh != null) eh (this, e);
  1187. }
  1188. }
  1189. protected virtual void OnCreatingUser (LoginCancelEventArgs e)
  1190. {
  1191. if (Events != null) {
  1192. LoginCancelEventHandler eh = (LoginCancelEventHandler) Events [CreatingUserEvent];
  1193. if (eh != null) eh (this, e);
  1194. }
  1195. }
  1196. protected override void OnNextButtonClick (WizardNavigationEventArgs e)
  1197. {
  1198. if (ActiveStep == CreateUserStep) {
  1199. bool userCreated = CreateUser ();
  1200. if (!userCreated)
  1201. e.Cancel = true;
  1202. else
  1203. if (LoginCreatedUser)
  1204. Login ();
  1205. }
  1206. base.OnNextButtonClick (e);
  1207. }
  1208. protected internal override void OnPreRender (EventArgs e)
  1209. {
  1210. base.OnPreRender (e);
  1211. }
  1212. protected virtual void OnSendingMail (MailMessageEventArgs e)
  1213. {
  1214. if (Events != null) {
  1215. MailMessageEventHandler eh = (MailMessageEventHandler) Events [SendingMailEvent];
  1216. if (eh != null) eh (this, e);
  1217. }
  1218. }
  1219. protected virtual void OnSendMailError (SendMailErrorEventArgs e)
  1220. {
  1221. if (Events != null) {
  1222. SendMailErrorEventHandler eh = (SendMailErrorEventHandler) Events [SendMailErrorEvent];
  1223. if (eh != null) eh (this, e);
  1224. }
  1225. }
  1226. protected override void LoadViewState (object savedState)
  1227. {
  1228. if (savedState == null) {
  1229. base.LoadViewState (null);
  1230. return;
  1231. }
  1232. object [] states = (object []) savedState;
  1233. base.LoadViewState (states [0]);
  1234. if (states [1] != null)
  1235. ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
  1236. if (states [2] != null)
  1237. ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
  1238. if (states [3] != null)
  1239. ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
  1240. if (states [4] != null)
  1241. ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
  1242. if (states [5] != null)
  1243. ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
  1244. if (states [6] != null)
  1245. ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
  1246. if (states [7] != null)
  1247. ((IStateManager) LabelStyle).LoadViewState (states [7]);
  1248. if (states [8] != null)
  1249. ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
  1250. if (states [9] != null)
  1251. ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
  1252. if (states [10] != null)
  1253. ((IStateManager) CreateUserButtonStyle).LoadViewState (states [10]);
  1254. if (states [11] != null)
  1255. ((IStateManager) ContinueButtonStyle).LoadViewState (states [11]);
  1256. if (states [12] != null)
  1257. ((IStateManager) MailDefinition).LoadViewState (states [12]);
  1258. ((CreateUserStepContainer) CreateUserStep.ContentTemplateContainer).EnsureValidatorsState ();
  1259. }
  1260. protected override object SaveViewState ()
  1261. {
  1262. object [] state = new object [13];
  1263. state [0] = base.SaveViewState ();
  1264. if (_textBoxStyle != null)
  1265. state [1] = ((IStateManager) _textBoxStyle).SaveViewState ();
  1266. if (_validatorTextStyle != null)
  1267. state [2] = ((IStateManager) _validatorTextStyle).SaveViewState ();
  1268. if (_completeSuccessTextStyle != null)
  1269. state [3] = ((IStateManager) _completeSuccessTextStyle).SaveViewState ();
  1270. if (_errorMessageStyle != null)
  1271. state [4] = ((IStateManager) _errorMessageStyle).SaveViewState ();
  1272. if (_hyperLinkStyle != null)
  1273. state [5] = ((IStateManager) _hyperLinkStyle).SaveViewState ();
  1274. if (_instructionTextStyle != null)
  1275. state [6] = ((IStateManager) _instructionTextStyle).SaveViewState ();
  1276. if (_labelStyle != null)
  1277. state [7] = ((IStateManager) _labelStyle).SaveViewState ();
  1278. if (_passwordHintStyle != null)
  1279. state [8] = ((IStateManager) _passwordHintStyle).SaveViewState ();
  1280. if (_titleTextStyle != null)
  1281. state [9] = ((IStateManager) _titleTextStyle).SaveViewState ();
  1282. if (_createUserButtonStyle != null)
  1283. state [10] = ((IStateManager) _createUserButtonStyle).SaveViewState ();
  1284. if (_continueButtonStyle != null)
  1285. state [11] = ((IStateManager) _continueButtonStyle).SaveViewState ();
  1286. if (_mailDefinition != null)
  1287. state [12] = ((IStateManager) _mailDefinition).SaveViewState ();
  1288. for (int n = 0; n < state.Length; n++)
  1289. if (state [n] != null)
  1290. return state;
  1291. return null;
  1292. }
  1293. [MonoTODO ("for design-time usage - no more details available")]
  1294. protected override void SetDesignModeState (IDictionary data)
  1295. {
  1296. base.SetDesignModeState (data);
  1297. }
  1298. protected override void TrackViewState ()
  1299. {
  1300. base.TrackViewState ();
  1301. if (_textBoxStyle != null)
  1302. ((IStateManager) _textBoxStyle).TrackViewState ();
  1303. if (_validatorTextStyle != null)
  1304. ((IStateManager) _validatorTextStyle).TrackViewState ();
  1305. if (_completeSuccessTextStyle != null)
  1306. ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
  1307. if (_errorMessageStyle != null)
  1308. ((IStateManager) _errorMessageStyle).TrackViewState ();
  1309. if (_hyperLinkStyle != null)
  1310. ((IStateManager) _hyperLinkStyle).TrackViewState ();
  1311. if (_instructionTextStyle != null)
  1312. ((IStateManager) _instructionTextStyle).TrackViewState ();
  1313. if (_labelStyle != null)
  1314. ((IStateManager) _labelStyle).TrackViewState ();
  1315. if (_passwordHintStyle != null)
  1316. ((IStateManager) _passwordHintStyle).TrackViewState ();
  1317. if (_titleTextStyle != null)
  1318. ((IStateManager) _titleTextStyle).TrackViewState ();
  1319. if (_createUserButtonStyle != null)
  1320. ((IStateManager) _createUserButtonStyle).TrackViewState ();
  1321. if (_continueButtonStyle != null)
  1322. ((IStateManager) _continueButtonStyle).TrackViewState ();
  1323. if (_mailDefinition != null)
  1324. ((IStateManager) _mailDefinition).TrackViewState ();
  1325. }
  1326. #endregion
  1327. #region Private event handlers
  1328. private void UserName_TextChanged (object sender, EventArgs e)
  1329. {
  1330. UserName = ((ITextControl) sender).Text;
  1331. }
  1332. private void Password_TextChanged (object sender, EventArgs e)
  1333. {
  1334. _password = ((ITextControl) sender).Text;
  1335. }
  1336. private void ConfirmPassword_TextChanged (object sender, EventArgs e)
  1337. {
  1338. _confirmPassword = ((ITextControl) sender).Text;
  1339. }
  1340. private void Email_TextChanged (object sender, EventArgs e)
  1341. {
  1342. Email = ((ITextControl) sender).Text;
  1343. }
  1344. private void Question_TextChanged (object sender, EventArgs e)
  1345. {
  1346. Question = ((ITextControl) sender).Text;
  1347. }
  1348. private void Answer_TextChanged (object sender, EventArgs e)
  1349. {
  1350. Answer = ((ITextControl) sender).Text;
  1351. }
  1352. #endregion
  1353. #region Private Methods
  1354. private void InitMemberShipProvider ()
  1355. {
  1356. string mp = MembershipProvider;
  1357. _provider = (mp.Length == 0) ? _provider = Membership.Provider : Membership.Providers [mp];
  1358. if (_provider == null)
  1359. throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
  1360. }
  1361. private bool CreateUser ()
  1362. {
  1363. if (!Page.IsValid)
  1364. return false;
  1365. if (AutoGeneratePassword)
  1366. _password = GeneratePassword ();
  1367. OnCreatingUser (new LoginCancelEventArgs (false));
  1368. MembershipCreateStatus status;
  1369. MembershipUser newUser = MembershipProviderInternal.CreateUser (
  1370. UserName, Password, Email, Question, Answer, !DisableCreatedUser, null, out status);
  1371. if ((newUser != null) && (status == MembershipCreateStatus.Success)) {
  1372. OnCreatedUser (new EventArgs ());
  1373. SendPasswordByMail (newUser, Password);
  1374. return true;
  1375. }
  1376. switch (status) {
  1377. case MembershipCreateStatus.DuplicateUserName:
  1378. ShowErrorMessage (DuplicateUserNameErrorMessage);
  1379. break;
  1380. case MembershipCreateStatus.InvalidPassword:
  1381. ShowErrorMessage (String.Format (InvalidPasswordErrorMessage, MembershipProviderInternal.MinRequiredPasswordLength, MembershipProviderInternal.MinRequiredNonAlphanumericCharacters));
  1382. break;
  1383. case MembershipCreateStatus.DuplicateEmail:
  1384. ShowErrorMessage (DuplicateEmailErrorMessage);
  1385. break;
  1386. case MembershipCreateStatus.InvalidEmail:
  1387. ShowErrorMessage (InvalidEmailErrorMessage);
  1388. break;
  1389. case MembershipCreateStatus.InvalidQuestion:
  1390. ShowErrorMessage (InvalidQuestionErrorMessage);
  1391. break;
  1392. case MembershipCreateStatus.InvalidAnswer:
  1393. ShowErrorMessage (InvalidAnswerErrorMessage);
  1394. break;
  1395. case MembershipCreateStatus.UserRejected:
  1396. case MembershipCreateStatus.InvalidUserName:
  1397. case MembershipCreateStatus.ProviderError:
  1398. case MembershipCreateStatus.InvalidProviderUserKey:
  1399. ShowErrorMessage (UnknownErrorMessage);
  1400. break;
  1401. }
  1402. OnCreateUserError (new CreateUserErrorEventArgs (status));
  1403. return false;
  1404. }
  1405. private void SendPasswordByMail (MembershipUser user, string password)
  1406. {
  1407. if (user == null)
  1408. return;
  1409. if (_mailDefinition == null)
  1410. return;
  1411. 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%>";
  1412. ListDictionary dictionary = new ListDictionary ();
  1413. dictionary.Add ("<%USERNAME%>", user.UserName);
  1414. dictionary.Add ("<%PASSWORD%>", password);
  1415. MailMessage message = null;
  1416. if (MailDefinition.BodyFileName.Length == 0)
  1417. message = MailDefinition.CreateMailMessage (user.Email, dictionary, messageText, this);
  1418. else
  1419. message = MailDefinition.CreateMailMessage (user.Email, dictionary, this);
  1420. if (string.IsNullOrEmpty (message.Subject))
  1421. message.Subject = "Account information";
  1422. MailMessageEventArgs args = new MailMessageEventArgs (message);
  1423. OnSendingMail (args);
  1424. SmtpClient smtpClient = new SmtpClient ();
  1425. try {
  1426. smtpClient.Send (message);
  1427. } catch (Exception e) {
  1428. SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e);
  1429. OnSendMailError (mailArgs);
  1430. if (!mailArgs.Handled)
  1431. throw e;
  1432. }
  1433. }
  1434. private void Login ()
  1435. {
  1436. bool userValidated = MembershipProviderInternal.ValidateUser (UserName, Password);
  1437. if (userValidated)
  1438. FormsAuthentication.SetAuthCookie (UserName, false);
  1439. }
  1440. private void ShowErrorMessage (string errorMessage)
  1441. {
  1442. if (_errorMessageLabel != null)
  1443. _errorMessageLabel.Text = errorMessage;
  1444. }
  1445. private string GeneratePassword ()
  1446. {
  1447. return Membership.GeneratePassword (8, 3);
  1448. }
  1449. #endregion
  1450. #region SideBarLabelTemplate
  1451. class SideBarLabelTemplate : ITemplate
  1452. {
  1453. Wizard wizard;
  1454. public SideBarLabelTemplate (Wizard wizard)
  1455. {
  1456. this.wizard = wizard;
  1457. }
  1458. public void InstantiateIn (Control control)
  1459. {
  1460. Label b = new Label ();
  1461. wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
  1462. control.Controls.Add (b);
  1463. control.DataBinding += Bound;
  1464. }
  1465. void Bound (object s, EventArgs args)
  1466. {
  1467. WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
  1468. if (step != null) {
  1469. Control c = (Control) s;
  1470. Label b = (Label) c.Controls [0];
  1471. b.ID = SideBarButtonID;
  1472. b.Text = step.Title;
  1473. }
  1474. }
  1475. }
  1476. #endregion
  1477. sealed class CreateUserNavigationContainer : DefaultNavigationContainer
  1478. {
  1479. CreateUserWizard _createUserWizard;
  1480. public CreateUserNavigationContainer (CreateUserWizard createUserWizard)
  1481. : base (createUserWizard)
  1482. {
  1483. _createUserWizard = createUserWizard;
  1484. }
  1485. protected override void UpdateState ()
  1486. {
  1487. // previous
  1488. if (_createUserWizard.AllowNavigationToStep (_createUserWizard.ActiveStepIndex - 1)) {
  1489. UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
  1490. }
  1491. else {
  1492. ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
  1493. }
  1494. // create user
  1495. UpdateNavButtonState (Wizard.StepNextButtonID + _createUserWizard.CreateUserButtonType, _createUserWizard.CreateUserButtonText, _createUserWizard.CreateUserButtonImageUrl, _createUserWizard.CreateUserButtonStyle);
  1496. // cancel
  1497. if (Wizard.DisplayCancelButton) {
  1498. UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
  1499. }
  1500. else {
  1501. ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
  1502. }
  1503. }
  1504. }
  1505. sealed class CreateUserStepNavigationTemplate : ITemplate
  1506. {
  1507. readonly CreateUserWizard _createUserWizard;
  1508. public CreateUserStepNavigationTemplate (CreateUserWizard createUserWizard) {
  1509. _createUserWizard = createUserWizard;
  1510. }
  1511. #region ITemplate Members
  1512. public void InstantiateIn (Control container) {
  1513. Table t = new Table ();
  1514. t.CellPadding = 5;
  1515. t.CellSpacing = 5;
  1516. t.Width = Unit.Percentage (100);
  1517. t.Height = Unit.Percentage (100);
  1518. TableRow row = new TableRow ();
  1519. AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepPreviousButtonID, Wizard.MovePreviousCommandName, false));
  1520. AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepNextButtonID, Wizard.MoveNextCommandName));
  1521. AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.CancelButtonID, Wizard.CancelCommandName, false));
  1522. t.Rows.Add (row);
  1523. container.Controls.Add (t);
  1524. }
  1525. void AddButtonCell (TableRow row, params Control [] controls)
  1526. {
  1527. TableCell cell = new TableCell ();
  1528. cell.HorizontalAlign = HorizontalAlign.Right;
  1529. for (int i = 0; i < controls.Length; i++)
  1530. cell.Controls.Add (controls[i]);
  1531. row.Cells.Add (cell);
  1532. }
  1533. #endregion
  1534. }
  1535. sealed class CreateUserStepContainer : DefaultContentContainer
  1536. {
  1537. CreateUserWizard _createUserWizard;
  1538. public CreateUserStepContainer (CreateUserWizard createUserWizard)
  1539. : base (createUserWizard)
  1540. {
  1541. _createUserWizard = createUserWizard;
  1542. }
  1543. public Control UserNameTextBox {
  1544. get {
  1545. Control c = FindControl ("UserName");
  1546. if (c == null)
  1547. throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID UserName for the username.");
  1548. return c;
  1549. }
  1550. }
  1551. public Control PasswordTextBox {
  1552. get {
  1553. Control c = FindControl ("Password");
  1554. if (c == null)
  1555. throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Password for the new password, this is required if AutoGeneratePassword = true.");
  1556. return c;
  1557. }
  1558. }
  1559. public Control ConfirmPasswordTextBox {
  1560. get {
  1561. Control c = FindControl ("Password");
  1562. return c;
  1563. }
  1564. }
  1565. public Control EmailTextBox {
  1566. get {
  1567. Control c = FindControl ("Email");
  1568. if (c == null)
  1569. throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.");
  1570. return c;
  1571. }
  1572. }
  1573. public Control QuestionTextBox {
  1574. get {
  1575. Control c = FindControl ("Question");
  1576. if (c == null)
  1577. 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.");
  1578. return c;
  1579. }
  1580. }
  1581. public Control AnswerTextBox {
  1582. get {
  1583. Control c = FindControl ("Answer");
  1584. if (c == null)
  1585. 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.");
  1586. return c;
  1587. }
  1588. }
  1589. public ITextControl ErrorMessageLabel {
  1590. get { return FindControl ("ErrorMessage") as ITextControl; }
  1591. }
  1592. protected override void UpdateState () {
  1593. // Row #0 - title
  1594. if (String.IsNullOrEmpty (_createUserWizard.CreateUserStep.Title)) {
  1595. ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
  1596. }
  1597. else {
  1598. ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CreateUserStep.Title;
  1599. }
  1600. // Row #1 - InstructionText
  1601. if (String.IsNullOrEmpty (_createUserWizard.InstructionText)) {
  1602. ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
  1603. }
  1604. else {
  1605. ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.InstructionText;
  1606. }
  1607. // Row #2
  1608. Label UserNameLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [2].Cells [0].Controls [0];
  1609. UserNameLabel.Text = _createUserWizard.UserNameLabelText;
  1610. RequiredFieldValidator UserNameRequired = (RequiredFieldValidator) FindControl ("UserNameRequired");
  1611. UserNameRequired.ErrorMessage = _createUserWizard.UserNameRequiredErrorMessage;
  1612. UserNameRequired.ToolTip = _createUserWizard.UserNameRequiredErrorMessage;
  1613. if (_createUserWizard.AutoGeneratePassword) {
  1614. ((Table) InnerCell.Controls [0]).Rows [3].Visible = false;
  1615. ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
  1616. ((Table) InnerCell.Controls [0]).Rows [5].Visible = false;
  1617. }
  1618. else {
  1619. // Row #3
  1620. Label PasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
  1621. PasswordLabel.Text = _createUserWizard.PasswordLabelText;
  1622. RequiredFieldValidator PasswordRequired = (RequiredFieldValidator) FindControl ("PasswordRequired");
  1623. PasswordRequired.ErrorMessage = _createUserWizard.PasswordRequiredErrorMessage;
  1624. PasswordRequired.ToolTip = _createUserWizard.PasswordRequiredErrorMessage;
  1625. // Row #4
  1626. if (String.IsNullOrEmpty (_createUserWizard.PasswordHintText)) {
  1627. ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
  1628. }
  1629. else {
  1630. ((Table) InnerCell.Controls [0]).Rows [4].Cells [1].Text = _createUserWizard.PasswordHintText;
  1631. }
  1632. // Row #5
  1633. Label ConfirmPasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [5].Cells [0].Controls [0];
  1634. ConfirmPasswordLabel.Text = _createUserWizard.ConfirmPasswordLabelText;
  1635. RequiredFieldValidator ConfirmPasswordRequired = (RequiredFieldValidator) FindControl ("ConfirmPasswordRequired");
  1636. ConfirmPasswordRequired.ErrorMessage = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
  1637. ConfirmPasswordRequired.ToolTip = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
  1638. }
  1639. // Row #6
  1640. if (_createUserWizard.RequireEmail) {
  1641. Label EmailLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [6].Cells [0].Controls [0];
  1642. EmailLabel.Text = _createUserWizard.EmailLabelText;
  1643. RequiredFieldValidator EmailRequired = (RequiredFieldValidator) FindControl ("EmailRequired");
  1644. EmailRequired.ErrorMessage = _createUserWizard.EmailRequiredErrorMessage;
  1645. EmailRequired.ToolTip = _createUserWizard.EmailRequiredErrorMessage;
  1646. }
  1647. else {
  1648. ((Table) InnerCell.Controls [0]).Rows [6].Visible = false;
  1649. }
  1650. if (_createUserWizard.QuestionAndAnswerRequired) {
  1651. // Row #7
  1652. Label QuestionLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [7].Cells [0].Controls [0];
  1653. QuestionLabel.Text = _createUserWizard.QuestionLabelText;
  1654. RequiredFieldValidator QuestionRequired = (RequiredFieldValidator) FindControl ("QuestionRequired");
  1655. QuestionRequired.ErrorMessage = _createUserWizard.QuestionRequiredErrorMessage;
  1656. QuestionRequired.ToolTip = _createUserWizard.QuestionRequiredErrorMessage;
  1657. // Row #8
  1658. Label AnswerLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [8].Cells [0].Controls [0];
  1659. AnswerLabel.Text = _createUserWizard.AnswerLabelText;
  1660. RequiredFieldValidator AnswerRequired = (RequiredFieldValidator) FindControl ("AnswerRequired");
  1661. AnswerRequired.ErrorMessage = _createUserWizard.AnswerRequiredErrorMessage;
  1662. AnswerRequired.ToolTip = _createUserWizard.AnswerRequiredErrorMessage;
  1663. }
  1664. else {
  1665. ((Table) InnerCell.Controls [0]).Rows [7].Visible = false;
  1666. ((Table) InnerCell.Controls [0]).Rows [8].Visible = false;
  1667. }
  1668. // Row #9
  1669. if (_createUserWizard.AutoGeneratePassword) {
  1670. ((Table) InnerCell.Controls [0]).Rows [9].Visible = false;
  1671. }
  1672. else {
  1673. CompareValidator PasswordCompare = (CompareValidator) FindControl ("PasswordCompare");
  1674. PasswordCompare.ErrorMessage = _createUserWizard.ConfirmPasswordCompareErrorMessage;
  1675. }
  1676. // Row #10
  1677. if (_createUserWizard.AutoGeneratePassword || String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression)) {
  1678. ((Table) InnerCell.Controls [0]).Rows [10].Visible = false;
  1679. }
  1680. else {
  1681. RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
  1682. PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
  1683. PasswordRegEx.ErrorMessage = _createUserWizard.PasswordRegularExpressionErrorMessage;
  1684. }
  1685. // Row #11
  1686. if (!_createUserWizard.RequireEmail || String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression)) {
  1687. ((Table) InnerCell.Controls [0]).Rows [11].Visible = false;
  1688. }
  1689. else {
  1690. RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
  1691. EmailRegEx.ErrorMessage = _createUserWizard.EmailRegularExpressionErrorMessage;
  1692. EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
  1693. }
  1694. // Row #12
  1695. if (String.IsNullOrEmpty (ErrorMessageLabel.Text)) {
  1696. ((Table) InnerCell.Controls [0]).Rows [12].Visible = false;
  1697. }
  1698. // Row #13
  1699. // HelpPageIconUrl
  1700. Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [0];
  1701. if (String.IsNullOrEmpty (_createUserWizard.HelpPageIconUrl)) {
  1702. img.Visible = false;
  1703. }
  1704. else {
  1705. img.ImageUrl = _createUserWizard.HelpPageIconUrl;
  1706. img.AlternateText = _createUserWizard.HelpPageText;
  1707. }
  1708. // HelpPageText
  1709. HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [1];
  1710. if (String.IsNullOrEmpty (_createUserWizard.HelpPageText)) {
  1711. link.Visible = false;
  1712. }
  1713. else {
  1714. link.Text = _createUserWizard.HelpPageText;
  1715. link.NavigateUrl = _createUserWizard.HelpPageUrl;
  1716. }
  1717. ((Table) InnerCell.Controls [0]).Rows [13].Visible = img.Visible || link.Visible;
  1718. }
  1719. public void EnsureValidatorsState ()
  1720. {
  1721. if (!IsDefaultTemplate)
  1722. return;
  1723. ((RequiredFieldValidator) FindControl ("PasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
  1724. ((RequiredFieldValidator) FindControl ("ConfirmPasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
  1725. ((CompareValidator) FindControl ("PasswordCompare")).Enabled = !_createUserWizard.AutoGeneratePassword;
  1726. RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
  1727. PasswordRegEx.Enabled = !_createUserWizard.AutoGeneratePassword && !String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression);
  1728. PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
  1729. ((RequiredFieldValidator) FindControl ("EmailRequired")).Enabled = _createUserWizard.RequireEmail;
  1730. RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
  1731. EmailRegEx.Enabled = _createUserWizard.RequireEmail && !String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression);
  1732. EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
  1733. ((RequiredFieldValidator) FindControl ("QuestionRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
  1734. ((RequiredFieldValidator) FindControl ("AnswerRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
  1735. }
  1736. }
  1737. sealed class CreateUserStepTemplate : ITemplate
  1738. {
  1739. readonly CreateUserWizard _createUserWizard;
  1740. public CreateUserStepTemplate (CreateUserWizard createUserWizard)
  1741. {
  1742. _createUserWizard = createUserWizard;
  1743. }
  1744. #region ITemplate Members
  1745. TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1) {
  1746. TableRow row = new TableRow ();
  1747. TableCell cell0 = new TableCell ();
  1748. TableCell cell1 = new TableCell ();
  1749. if (c0 != null)
  1750. cell0.Controls.Add (c0);
  1751. row.Controls.Add (cell0);
  1752. if ((c1 != null) && (c2 != null)) {
  1753. cell1.Controls.Add (c1);
  1754. cell1.Controls.Add (c2);
  1755. cell0.HorizontalAlign = HorizontalAlign.Right;
  1756. if (s0 != null)
  1757. _createUserWizard.RegisterApplyStyle (cell0, s0);
  1758. if (s1 != null)
  1759. _createUserWizard.RegisterApplyStyle (cell1, s1);
  1760. row.Controls.Add (cell1);
  1761. }
  1762. else {
  1763. cell0.ColumnSpan = 2;
  1764. cell0.HorizontalAlign = HorizontalAlign.Center;
  1765. if (s0 != null)
  1766. _createUserWizard.RegisterApplyStyle (cell0, s0);
  1767. }
  1768. return row;
  1769. }
  1770. public void InstantiateIn (Control container) {
  1771. Table table = new Table ();
  1772. table.ControlStyle.Width = Unit.Percentage (100);
  1773. table.ControlStyle.Height = Unit.Percentage (100);
  1774. // Row #0
  1775. table.Controls.Add (CreateRow (null, null, null, _createUserWizard.TitleTextStyle, null));
  1776. // Row #1
  1777. table.Controls.Add (CreateRow (null, null, null, _createUserWizard.InstructionTextStyle, null));
  1778. // Row #2
  1779. TextBox UserName = new TextBox ();
  1780. UserName.ID = "UserName";
  1781. _createUserWizard.RegisterApplyStyle (UserName, _createUserWizard.TextBoxStyle);
  1782. Label UserNameLabel = new Label ();
  1783. UserNameLabel.AssociatedControlID = "UserName";
  1784. RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
  1785. UserNameRequired.ID = "UserNameRequired";
  1786. // alternatively we can create only required validators
  1787. // and reinstantiate collection when relevant property changes
  1788. UserNameRequired.EnableViewState = false;
  1789. UserNameRequired.ControlToValidate = "UserName";
  1790. UserNameRequired.Text = "*";
  1791. UserNameRequired.ValidationGroup = _createUserWizard.ID;
  1792. _createUserWizard.RegisterApplyStyle (UserNameRequired, _createUserWizard.ValidatorTextStyle);
  1793. table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _createUserWizard.LabelStyle, null));
  1794. // Row #3
  1795. TextBox Password = new TextBox ();
  1796. Password.ID = "Password";
  1797. Password.TextMode = TextBoxMode.Password;
  1798. _createUserWizard.RegisterApplyStyle (Password, _createUserWizard.TextBoxStyle);
  1799. Label PasswordLabel = new Label ();
  1800. PasswordLabel.AssociatedControlID = "Password";
  1801. RequiredFieldValidator PasswordRequired = new RequiredFieldValidator ();
  1802. PasswordRequired.ID = "PasswordRequired";
  1803. PasswordRequired.EnableViewState = false;
  1804. PasswordRequired.ControlToValidate = "Password";
  1805. PasswordRequired.Text = "*";
  1806. //PasswordRequired.EnableViewState = false;
  1807. PasswordRequired.ValidationGroup = _createUserWizard.ID;
  1808. _createUserWizard.RegisterApplyStyle (PasswordRequired, _createUserWizard.ValidatorTextStyle);
  1809. table.Controls.Add (CreateRow (PasswordLabel, Password, PasswordRequired, _createUserWizard.LabelStyle, null));
  1810. // Row #4
  1811. table.Controls.Add (CreateRow (new LiteralControl (""), new LiteralControl (""), new LiteralControl (""), null, _createUserWizard.PasswordHintStyle));
  1812. // Row #5
  1813. TextBox ConfirmPassword = new TextBox ();
  1814. ConfirmPassword.ID = "ConfirmPassword";
  1815. ConfirmPassword.TextMode = TextBoxMode.Password;
  1816. _createUserWizard.RegisterApplyStyle (ConfirmPassword, _createUserWizard.TextBoxStyle);
  1817. Label ConfirmPasswordLabel = new Label ();
  1818. ConfirmPasswordLabel.AssociatedControlID = "ConfirmPassword";
  1819. RequiredFieldValidator ConfirmPasswordRequired = new RequiredFieldValidator ();
  1820. ConfirmPasswordRequired.ID = "ConfirmPasswordRequired";
  1821. ConfirmPasswordRequired.EnableViewState = false;
  1822. ConfirmPasswordRequired.ControlToValidate = "ConfirmPassword";
  1823. ConfirmPasswordRequired.Text = "*";
  1824. ConfirmPasswordRequired.ValidationGroup = _createUserWizard.ID;
  1825. _createUserWizard.RegisterApplyStyle (ConfirmPasswordRequired, _createUserWizard.ValidatorTextStyle);
  1826. table.Controls.Add (CreateRow (ConfirmPasswordLabel, ConfirmPassword, ConfirmPasswordRequired, _createUserWizard.LabelStyle, null));
  1827. // Row #6
  1828. TextBox Email = new TextBox ();
  1829. Email.ID = "Email";
  1830. _createUserWizard.RegisterApplyStyle (Email, _createUserWizard.TextBoxStyle);
  1831. Label EmailLabel = new Label ();
  1832. EmailLabel.AssociatedControlID = "Email";
  1833. RequiredFieldValidator EmailRequired = new RequiredFieldValidator ();
  1834. EmailRequired.ID = "EmailRequired";
  1835. EmailRequired.EnableViewState = false;
  1836. EmailRequired.ControlToValidate = "Email";
  1837. EmailRequired.Text = "*";
  1838. EmailRequired.ValidationGroup = _createUserWizard.ID;
  1839. _createUserWizard.RegisterApplyStyle (EmailRequired, _createUserWizard.ValidatorTextStyle);
  1840. table.Controls.Add (CreateRow (EmailLabel, Email, EmailRequired, _createUserWizard.LabelStyle, null));
  1841. // Row #7
  1842. TextBox Question = new TextBox ();
  1843. Question.ID = "Question";
  1844. _createUserWizard.RegisterApplyStyle (Question, _createUserWizard.TextBoxStyle);
  1845. Label QuestionLabel = new Label ();
  1846. QuestionLabel.AssociatedControlID = "Question";
  1847. RequiredFieldValidator QuestionRequired = new RequiredFieldValidator ();
  1848. QuestionRequired.ID = "QuestionRequired";
  1849. QuestionRequired.EnableViewState = false;
  1850. QuestionRequired.ControlToValidate = "Question";
  1851. QuestionRequired.Text = "*";
  1852. QuestionRequired.ValidationGroup = _createUserWizard.ID;
  1853. _createUserWizard.RegisterApplyStyle (QuestionRequired, _createUserWizard.ValidatorTextStyle);
  1854. table.Controls.Add (CreateRow (QuestionLabel, Question, QuestionRequired, _createUserWizard.LabelStyle, null));
  1855. // Row #8
  1856. TextBox Answer = new TextBox ();
  1857. Answer.ID = "Answer";
  1858. _createUserWizard.RegisterApplyStyle (Answer, _createUserWizard.TextBoxStyle);
  1859. Label AnswerLabel = new Label ();
  1860. AnswerLabel.AssociatedControlID = "Answer";
  1861. RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
  1862. AnswerRequired.ID = "AnswerRequired";
  1863. AnswerRequired.EnableViewState = false;
  1864. AnswerRequired.ControlToValidate = "Answer";
  1865. AnswerRequired.Text = "*";
  1866. AnswerRequired.ValidationGroup = _createUserWizard.ID;
  1867. _createUserWizard.RegisterApplyStyle (AnswerRequired, _createUserWizard.ValidatorTextStyle);
  1868. table.Controls.Add (CreateRow (AnswerLabel, Answer, AnswerRequired, _createUserWizard.LabelStyle, null));
  1869. // Row #9
  1870. CompareValidator PasswordCompare = new CompareValidator ();
  1871. PasswordCompare.ID = "PasswordCompare";
  1872. PasswordCompare.EnableViewState = false;
  1873. PasswordCompare.ControlToCompare = "Password";
  1874. PasswordCompare.ControlToValidate = "ConfirmPassword";
  1875. PasswordCompare.Display = ValidatorDisplay.Static;
  1876. PasswordCompare.ValidationGroup = _createUserWizard.ID;
  1877. PasswordCompare.Display = ValidatorDisplay.Dynamic;
  1878. _createUserWizard.RegisterApplyStyle (PasswordCompare, _createUserWizard.ValidatorTextStyle);
  1879. table.Controls.Add (CreateRow (PasswordCompare, null, null, null, null));
  1880. // Row #10
  1881. RegularExpressionValidator PasswordRegEx = new RegularExpressionValidator ();
  1882. PasswordRegEx.ID = "PasswordRegEx";
  1883. PasswordRegEx.EnableViewState = false;
  1884. PasswordRegEx.ControlToValidate = "Password";
  1885. PasswordRegEx.Display = ValidatorDisplay.Static;
  1886. PasswordRegEx.ValidationGroup = _createUserWizard.ID;
  1887. PasswordRegEx.Display = ValidatorDisplay.Dynamic;
  1888. _createUserWizard.RegisterApplyStyle (PasswordRegEx, _createUserWizard.ValidatorTextStyle);
  1889. table.Controls.Add (CreateRow (PasswordRegEx, null, null, null, null));
  1890. // Row #11
  1891. RegularExpressionValidator EmailRegEx = new RegularExpressionValidator ();
  1892. EmailRegEx.ID = "EmailRegEx";
  1893. EmailRegEx.EnableViewState = false;
  1894. EmailRegEx.ControlToValidate = "Email";
  1895. EmailRegEx.Display = ValidatorDisplay.Static;
  1896. EmailRegEx.ValidationGroup = _createUserWizard.ID;
  1897. EmailRegEx.Display = ValidatorDisplay.Dynamic;
  1898. _createUserWizard.RegisterApplyStyle (EmailRegEx, _createUserWizard.ValidatorTextStyle);
  1899. table.Controls.Add (CreateRow (EmailRegEx, null, null, null, null));
  1900. // Row #12
  1901. Label ErrorMessage = new Label ();
  1902. ErrorMessage.ID = "ErrorMessage";
  1903. ErrorMessage.EnableViewState = false;
  1904. _createUserWizard.RegisterApplyStyle (ErrorMessage, _createUserWizard.ValidatorTextStyle);
  1905. table.Controls.Add (CreateRow (ErrorMessage, null, null, null, null));
  1906. // Row #13
  1907. TableRow row13 = CreateRow (new Image (), null, null, null, null);
  1908. HyperLink HelpLink = new HyperLink ();
  1909. HelpLink.ID = "HelpLink";
  1910. _createUserWizard.RegisterApplyStyle (HelpLink, _createUserWizard.HyperLinkStyle);
  1911. row13.Cells [0].Controls.Add (HelpLink);
  1912. row13.Cells [0].HorizontalAlign = HorizontalAlign.Left;
  1913. table.Controls.Add (row13);
  1914. //
  1915. container.Controls.Add (table);
  1916. }
  1917. #endregion
  1918. }
  1919. sealed class CompleteStepContainer : DefaultContentContainer
  1920. {
  1921. CreateUserWizard _createUserWizard;
  1922. public CompleteStepContainer (CreateUserWizard createUserWizard)
  1923. : base (createUserWizard)
  1924. {
  1925. _createUserWizard = createUserWizard;
  1926. }
  1927. protected override void UpdateState ()
  1928. {
  1929. // title
  1930. if (String.IsNullOrEmpty (_createUserWizard.CompleteStep.Title)) {
  1931. ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
  1932. }
  1933. else {
  1934. ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CompleteStep.Title;
  1935. }
  1936. // CompleteSuccessText
  1937. if (String.IsNullOrEmpty (_createUserWizard.CompleteSuccessText)) {
  1938. ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
  1939. }
  1940. else {
  1941. ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.CompleteSuccessText;
  1942. }
  1943. // ContinueButton
  1944. UpdateNavButtonState ("ContinueButton" + _createUserWizard.ContinueButtonType, _createUserWizard.ContinueButtonText, _createUserWizard.ContinueButtonImageUrl, _createUserWizard.ContinueButtonStyle);
  1945. // EditProfileIconUrl
  1946. Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
  1947. if (String.IsNullOrEmpty (_createUserWizard.EditProfileIconUrl)) {
  1948. img.Visible = false;
  1949. }
  1950. else {
  1951. img.ImageUrl = _createUserWizard.EditProfileIconUrl;
  1952. img.AlternateText = _createUserWizard.EditProfileText;
  1953. }
  1954. // EditProfileText
  1955. HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [1];
  1956. if (String.IsNullOrEmpty (_createUserWizard.EditProfileText)) {
  1957. link.Visible = false;
  1958. }
  1959. else {
  1960. link.Text = _createUserWizard.EditProfileText;
  1961. link.NavigateUrl = _createUserWizard.EditProfileUrl;
  1962. }
  1963. ((Table) InnerCell.Controls [0]).Rows [3].Visible = img.Visible || link.Visible;
  1964. }
  1965. void UpdateNavButtonState (string id, string text, string image, Style style)
  1966. {
  1967. WebControl b = (WebControl) FindControl (id);
  1968. foreach (Control c in b.Parent.Controls)
  1969. c.Visible = b == c;
  1970. ((IButtonControl) b).Text = text;
  1971. ImageButton imgbtn = b as ImageButton;
  1972. if (imgbtn != null)
  1973. imgbtn.ImageUrl = image;
  1974. b.ApplyStyle (style);
  1975. }
  1976. }
  1977. sealed class CompleteStepTemplate : ITemplate
  1978. {
  1979. readonly CreateUserWizard _createUserWizard;
  1980. public CompleteStepTemplate (CreateUserWizard createUserWizard)
  1981. {
  1982. _createUserWizard = createUserWizard;
  1983. }
  1984. #region ITemplate Members
  1985. public void InstantiateIn (Control container)
  1986. {
  1987. Table table = new Table ();
  1988. // Row #0
  1989. TableRow row0 = new TableRow ();
  1990. TableCell cell00 = new TableCell ();
  1991. cell00.HorizontalAlign = HorizontalAlign.Center;
  1992. cell00.ColumnSpan = 2;
  1993. _createUserWizard.RegisterApplyStyle (cell00, _createUserWizard.TitleTextStyle);
  1994. row0.Cells.Add (cell00);
  1995. // Row #1
  1996. TableRow row1 = new TableRow ();
  1997. TableCell cell10 = new TableCell ();
  1998. cell10.HorizontalAlign = HorizontalAlign.Center;
  1999. _createUserWizard.RegisterApplyStyle (cell10, _createUserWizard.CompleteSuccessTextStyle);
  2000. row1.Cells.Add (cell10);
  2001. // Row #2
  2002. TableRow row2 = new TableRow ();
  2003. TableCell cell20 = new TableCell ();
  2004. cell20.HorizontalAlign = HorizontalAlign.Right;
  2005. cell20.ColumnSpan = 2;
  2006. row2.Cells.Add (cell20);
  2007. Control[] b = _createUserWizard.CreateButtonSet ("ContinueButton", CreateUserWizard.ContinueButtonCommandName);
  2008. for (int i = 0; i < b.Length; i++)
  2009. cell20.Controls.Add (b [i]);
  2010. // Row #3
  2011. TableRow row3 = new TableRow ();
  2012. TableCell cell30 = new TableCell ();
  2013. cell30.Controls.Add (new Image ());
  2014. HyperLink link = new HyperLink ();
  2015. link.ID = "EditProfileLink";
  2016. _createUserWizard.RegisterApplyStyle (link, _createUserWizard.HyperLinkStyle);
  2017. cell30.Controls.Add (link);
  2018. row3.Cells.Add (cell30);
  2019. // table
  2020. table.Rows.Add (row0);
  2021. table.Rows.Add (row1);
  2022. table.Rows.Add (row2);
  2023. table.Rows.Add (row3);
  2024. container.Controls.Add (table);
  2025. }
  2026. #endregion
  2027. }
  2028. }
  2029. }
  2030. #endif