Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / CreateUserWizard.cs / 1305376 / CreateUserWizard.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Linq;
using System.Security.Permissions;
using System.Web.Security;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.Util;
using System.Net.Mail;
using System.Text;
using System.Web.Management;
///
/// Displays UI that allows creating a user.
///
[
Bindable(false),
DefaultEvent("CreatedUser"),
Designer("System.Web.UI.Design.WebControls.CreateUserWizardDesigner, " + AssemblyRef.SystemDesign),
ToolboxData("<{0}:CreateUserWizard runat=\"server\"> {0}:CreateUserWizard>")
]
public class CreateUserWizard : Wizard {
public static readonly string ContinueButtonCommandName = "Continue";
private string _password;
private string _confirmPassword;
private string _answer;
private string _unknownErrorMessage;
private string _validationGroup;
private CreateUserWizardStep _createUserStep;
private CompleteWizardStep _completeStep;
private CreateUserStepContainer _createUserStepContainer;
private CompleteStepContainer _completeStepContainer;
private const string _userNameReplacementKey = "<%\\s*UserName\\s*%>";
private const string _passwordReplacementKey = "<%\\s*Password\\s*%>";
private bool _failure;
private bool _convertingToTemplate;
private DefaultCreateUserNavigationTemplate _defaultCreateUserNavigationTemplate;
private const int _viewStateArrayLength = 13;
private Style _createUserButtonStyle;
private TableItemStyle _labelStyle;
private Style _textBoxStyle;
private TableItemStyle _hyperLinkStyle;
private TableItemStyle _instructionTextStyle;
private TableItemStyle _titleTextStyle;
private TableItemStyle _errorMessageStyle;
private TableItemStyle _passwordHintStyle;
private Style _continueButtonStyle;
private TableItemStyle _completeSuccessTextStyle;
private Style _validatorTextStyle;
private MailDefinition _mailDefinition;
private static readonly object EventCreatingUser = new object();
private static readonly object EventCreateUserError = new object();
private static readonly object EventCreatedUser = new object();
private static readonly object EventButtonContinueClick = new object();
private static readonly object EventSendingMail = new object();
private static readonly object EventSendMailError = new object();
private const string _createUserNavigationTemplateName = "CreateUserNavigationTemplate";
// Needed for user template feature
private const string _userNameID = "UserName";
private const string _passwordID = "Password";
private const string _confirmPasswordID = "ConfirmPassword";
private const string _errorMessageID = "ErrorMessage";
private const string _emailID = "Email";
private const string _questionID = "Question";
private const string _answerID = "Answer";
// Needed only for "convert to template" feature, otherwise unnecessary
private const string _userNameRequiredID = "UserNameRequired";
private const string _passwordRequiredID = "PasswordRequired";
private const string _confirmPasswordRequiredID = "ConfirmPasswordRequired";
private const string _passwordRegExpID = "PasswordRegExp";
private const string _emailRegExpID = "EmailRegExp";
private const string _emailRequiredID = "EmailRequired";
private const string _questionRequiredID = "QuestionRequired";
private const string _answerRequiredID = "AnswerRequired";
private const string _passwordCompareID = "PasswordCompare";
private const string _continueButtonID = "ContinueButton";
private const string _helpLinkID = "HelpLink";
private const string _editProfileLinkID = "EditProfileLink";
private const string _createUserStepContainerID = "CreateUserStepContainer";
private const string _completeStepContainerID = "CompleteStepContainer";
private const string _sideBarLabelID = "SideBarLabel";
private const ValidatorDisplay _requiredFieldValidatorDisplay = ValidatorDisplay.Static;
private const ValidatorDisplay _compareFieldValidatorDisplay = ValidatorDisplay.Dynamic;
private const ValidatorDisplay _regexpFieldValidatorDisplay = ValidatorDisplay.Dynamic;
private TableRow _passwordHintTableRow;
private TableRow _questionRow;
private TableRow _answerRow;
private TableRow _emailRow;
private TableRow _passwordCompareRow;
private TableRow _passwordRegExpRow;
private TableRow _emailRegExpRow;
private TableRow _passwordTableRow;
private TableRow _confirmPasswordTableRow;
private const bool _displaySideBarDefaultValue = false;
///
/// Creates a new instance of a CreateUserWizard.
///
public CreateUserWizard()
: base(_displaySideBarDefaultValue) {
}
#region Public Properties
[
DefaultValue(0),
]
public override int ActiveStepIndex {
get {
return base.ActiveStepIndex;
}
set {
base.ActiveStepIndex = value;
}
}
///
/// Gets or sets the initial value in the answer textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
DefaultValue(""),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_Answer)
]
public virtual string Answer {
get {
return (_answer == null) ? String.Empty : _answer;
}
set {
_answer = value;
}
}
private string AnswerInternal {
get {
string answer = Answer;
if (String.IsNullOrEmpty(Answer) && _createUserStepContainer != null) {
ITextControl answerTextBox = (ITextControl)_createUserStepContainer.AnswerTextBox;
if (answerTextBox != null) {
answer = answerTextBox.Text;
}
}
// Pass Null instead of Empty into Membership
if (String.IsNullOrEmpty(answer)) {
answer = null;
}
return answer;
}
}
///
/// Gets or sets the text that identifies the question textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultAnswerLabelText),
WebSysDescription(SR.CreateUserWizard_AnswerLabelText)
]
public virtual string AnswerLabelText {
get {
object obj = ViewState["AnswerLabelText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultAnswerLabelText) : (string)obj;
}
set {
ViewState["AnswerLabelText"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the answer is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultAnswerRequiredErrorMessage),
WebSysDescription(SR.LoginControls_AnswerRequiredErrorMessage)
]
public virtual string AnswerRequiredErrorMessage {
get {
object obj = ViewState["AnswerRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultAnswerRequiredErrorMessage) : (string)obj;
}
set {
ViewState["AnswerRequiredErrorMessage"] = value;
}
}
[
WebCategory("Behavior"),
DefaultValue(false),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_AutoGeneratePassword)
]
public virtual bool AutoGeneratePassword {
get {
object obj = ViewState["AutoGeneratePassword"];
return (obj == null) ? false : (bool)obj;
}
set {
if (AutoGeneratePassword != value) {
ViewState["AutoGeneratePassword"] = value;
RequiresControlsRecreation();
}
}
}
///
/// Gets the complete step
///
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
WebCategory("Appearance"),
WebSysDescription(SR.CreateUserWizard_CompleteStep)
]
public CompleteWizardStep CompleteStep {
get {
EnsureChildControls();
return _completeStep;
}
}
///
/// The text to be shown after the password has been changed.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultCompleteSuccessText),
WebSysDescription(SR.CreateUserWizard_CompleteSuccessText)
]
public virtual string CompleteSuccessText {
get {
object obj = ViewState["CompleteSuccessText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultCompleteSuccessText) : (string)obj;
}
set {
ViewState["CompleteSuccessText"] = value;
}
}
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_CompleteSuccessTextStyle)
]
public TableItemStyle CompleteSuccessTextStyle {
get {
if (_completeSuccessTextStyle == null) {
_completeSuccessTextStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_completeSuccessTextStyle).TrackViewState();
}
}
return _completeSuccessTextStyle;
}
}
///
/// Gets the confirm new password entered by the user.
///
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public virtual string ConfirmPassword {
get {
return (_confirmPassword == null) ? String.Empty : _confirmPassword;
}
}
///
/// Gets or sets the message that is displayed for confirm password errors
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordCompareErrorMessage),
WebSysDescription(SR.ChangePassword_ConfirmPasswordCompareErrorMessage)
]
public virtual string ConfirmPasswordCompareErrorMessage {
get {
object obj = ViewState["ConfirmPasswordCompareErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordCompareErrorMessage) : (string)obj;
}
set {
ViewState["ConfirmPasswordCompareErrorMessage"] = value;
}
}
///
/// Gets or sets the text that identifies the new password textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordLabelText),
WebSysDescription(SR.CreateUserWizard_ConfirmPasswordLabelText)
]
public virtual string ConfirmPasswordLabelText {
get {
object obj = ViewState["ConfirmPasswordLabelText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordLabelText) : (string)obj;
}
set {
ViewState["ConfirmPasswordLabelText"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the confirm password is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultConfirmPasswordRequiredErrorMessage),
WebSysDescription(SR.LoginControls_ConfirmPasswordRequiredErrorMessage)
]
public virtual string ConfirmPasswordRequiredErrorMessage {
get {
object obj = ViewState["ConfirmPasswordRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultConfirmPasswordRequiredErrorMessage) : (string)obj;
}
set {
ViewState["ConfirmPasswordRequiredErrorMessage"] = value;
}
}
///
/// Gets or sets the URL of an image to be displayed for the continue button.
///
[
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.ChangePassword_ContinueButtonImageUrl),
Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string ContinueButtonImageUrl {
get {
object obj = ViewState["ContinueButtonImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["ContinueButtonImageUrl"] = value;
}
}
///
/// Gets the style of the continue button.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_ContinueButtonStyle)
]
public Style ContinueButtonStyle {
get {
if (_continueButtonStyle == null) {
_continueButtonStyle = new Style();
if (IsTrackingViewState) {
((IStateManager)_continueButtonStyle).TrackViewState();
}
}
return _continueButtonStyle;
}
}
///
/// Gets or sets the text to be shown for the continue button.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultContinueButtonText),
WebSysDescription(SR.CreateUserWizard_ContinueButtonText)
]
public virtual string ContinueButtonText {
get {
object obj = ViewState["ContinueButtonText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultContinueButtonText) : (string)obj;
}
set {
ViewState["ContinueButtonText"] = value;
}
}
///
/// Gets or sets the type of the continue button.
///
[
WebCategory("Appearance"),
DefaultValue(ButtonType.Button),
WebSysDescription(SR.CreateUserWizard_ContinueButtonType)
]
public virtual ButtonType ContinueButtonType {
get {
object obj = ViewState["ContinueButtonType"];
return (obj == null) ? ButtonType.Button : (ButtonType)obj;
}
set {
if (value < ButtonType.Button || value > ButtonType.Link) {
throw new ArgumentOutOfRangeException("value");
}
if (value != ContinueButtonType) {
ViewState["ContinueButtonType"] = value;
}
}
}
///
/// Gets or sets the URL of an image to be displayed for the continue button.
///
[
WebCategory("Behavior"),
DefaultValue(""),
WebSysDescription(SR.LoginControls_ContinueDestinationPageUrl),
Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
Themeable(false),
UrlProperty()
]
public virtual string ContinueDestinationPageUrl {
get {
object obj = ViewState["ContinueDestinationPageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["ContinueDestinationPageUrl"] = value;
}
}
private bool ConvertingToTemplate {
get {
return (DesignMode && _convertingToTemplate);
}
}
///
/// Gets the create user step
///
[
WebCategory("Appearance"),
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
WebSysDescription(SR.CreateUserWizard_CreateUserStep)
]
public CreateUserWizardStep CreateUserStep {
get {
EnsureChildControls();
return _createUserStep;
}
}
///
/// Gets or sets the URL of an image to be displayed for the create user button.
///
[
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.CreateUserWizard_CreateUserButtonImageUrl),
Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string CreateUserButtonImageUrl {
get {
object obj = ViewState["CreateUserButtonImageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["CreateUserButtonImageUrl"] = value;
}
}
///
/// Gets the style of the createUser button.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_CreateUserButtonStyle)
]
public Style CreateUserButtonStyle {
get {
if (_createUserButtonStyle == null) {
_createUserButtonStyle = new Style();
if (IsTrackingViewState) {
((IStateManager)_createUserButtonStyle).TrackViewState();
}
}
return _createUserButtonStyle;
}
}
///
/// Gets or sets the text to be shown for the continue button.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultCreateUserButtonText),
WebSysDescription(SR.CreateUserWizard_CreateUserButtonText)
]
public virtual string CreateUserButtonText {
get {
object obj = ViewState["CreateUserButtonText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultCreateUserButtonText) : (string)obj;
}
set {
ViewState["CreateUserButtonText"] = value;
}
}
///
/// Gets or sets the type of the continue button.
///
[
WebCategory("Appearance"),
DefaultValue(ButtonType.Button),
WebSysDescription(SR.CreateUserWizard_CreateUserButtonType)
]
public virtual ButtonType CreateUserButtonType {
get {
object obj = ViewState["CreateUserButtonType"];
return (obj == null) ? ButtonType.Button : (ButtonType)obj;
}
set {
if (value < ButtonType.Button || value > ButtonType.Link) {
throw new ArgumentOutOfRangeException("value");
}
if (value != CreateUserButtonType) {
ViewState["CreateUserButtonType"] = value;
}
}
}
private bool DefaultCreateUserStep {
get {
CreateUserWizardStep step = CreateUserStep;
return (step == null) ? false : step.ContentTemplate == null;
}
}
private bool DefaultCompleteStep {
get {
CompleteWizardStep step = CompleteStep;
return (step == null) ? false : step.ContentTemplate == null;
}
}
///
/// Gets or sets whether the created user will be disabled
///
[
WebCategory("Behavior"),
DefaultValue(false),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_DisableCreatedUser)
]
public virtual bool DisableCreatedUser {
get {
object obj = ViewState["DisableCreatedUser"];
return (obj == null) ? false : (bool)obj;
}
set {
ViewState["DisableCreatedUser"] = value;
}
}
[
DefaultValue(false)
]
public override bool DisplaySideBar {
get {
return base.DisplaySideBar;
}
set {
base.DisplaySideBar = value;
}
}
///
/// Gets or sets the message that is displayed for duplicate emails
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultDuplicateEmailErrorMessage),
WebSysDescription(SR.CreateUserWizard_DuplicateEmailErrorMessage)
]
public virtual string DuplicateEmailErrorMessage {
get {
object obj = ViewState["DuplicateEmailErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultDuplicateEmailErrorMessage) : (string)obj;
}
set {
ViewState["DuplicateEmailErrorMessage"] = value;
}
}
///
/// Gets or sets the message that is displayed for email errors
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultDuplicateUserNameErrorMessage),
WebSysDescription(SR.CreateUserWizard_DuplicateUserNameErrorMessage)
]
public virtual string DuplicateUserNameErrorMessage {
get {
object obj = ViewState["DuplicateUserNameErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultDuplicateUserNameErrorMessage) : (string)obj;
}
set {
ViewState["DuplicateUserNameErrorMessage"] = value;
}
}
///
/// Gets or sets the URL for the image shown next to the profile page.
///
[
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.LoginControls_EditProfileIconUrl),
Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string EditProfileIconUrl {
get {
object obj = ViewState["EditProfileIconUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["EditProfileIconUrl"] = value;
}
}
///
/// Gets or sets the text to be shown for the edit profile page
///
[
Localizable(true),
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.CreateUserWizard_EditProfileText)
]
public virtual string EditProfileText {
get {
object obj = ViewState["EditProfileText"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["EditProfileText"] = value;
}
}
///
/// Gets or sets the URL of the edit profile page.
///
[
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.CreateUserWizard_EditProfileUrl),
Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string EditProfileUrl {
get {
object obj = ViewState["EditProfileUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["EditProfileUrl"] = value;
}
}
///
/// Gets or sets the initial value in the Email textbox.
///
[
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.CreateUserWizard_Email)
]
public virtual string Email {
get {
object obj = ViewState["Email"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["Email"] = value;
}
}
private string EmailInternal {
get {
string email = Email;
if (String.IsNullOrEmpty(email) && _createUserStepContainer != null) {
ITextControl emailTextBox = (ITextControl)_createUserStepContainer.EmailTextBox;
if (emailTextBox != null) {
return emailTextBox.Text;
}
}
return email;
}
}
///
/// Gets or sets the text that identifies the email textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailLabelText),
WebSysDescription(SR.CreateUserWizard_EmailLabelText)
]
public virtual string EmailLabelText {
get {
object obj = ViewState["EmailLabelText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailLabelText) : (string)obj;
}
set {
ViewState["EmailLabelText"] = value;
}
}
///
/// Regular expression used to validate the email address
///
[
WebCategory("Validation"),
WebSysDefaultValue(""),
WebSysDescription(SR.CreateUserWizard_EmailRegularExpression)
]
public virtual string EmailRegularExpression {
get {
object obj = ViewState["EmailRegularExpression"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["EmailRegularExpression"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the email fails the reg exp.
///
[
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailRegularExpressionErrorMessage),
WebSysDescription(SR.CreateUserWizard_EmailRegularExpressionErrorMessage)
]
public virtual string EmailRegularExpressionErrorMessage {
get {
object obj = ViewState["EmailRegularExpressionErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailRegularExpressionErrorMessage) : (string)obj;
}
set {
ViewState["EmailRegularExpressionErrorMessage"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the email is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultEmailRequiredErrorMessage),
WebSysDescription(SR.CreateUserWizard_EmailRequiredErrorMessage)
]
public virtual string EmailRequiredErrorMessage {
get {
object obj = ViewState["EmailRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultEmailRequiredErrorMessage) : (string)obj;
}
set {
ViewState["EmailRequiredErrorMessage"] = value;
}
}
///
/// Gets or sets the text that is displayed for unknown errors
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultUnknownErrorMessage),
WebSysDescription(SR.CreateUserWizard_UnknownErrorMessage)
]
public virtual string UnknownErrorMessage {
get {
object obj = ViewState["UnknownErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUnknownErrorMessage) : (string)obj;
}
set {
ViewState["UnknownErrorMessage"] = value;
}
}
///
/// Gets the style of the error message.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_ErrorMessageStyle)
]
public TableItemStyle ErrorMessageStyle {
get {
if (_errorMessageStyle == null) {
_errorMessageStyle = new ErrorTableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_errorMessageStyle).TrackViewState();
}
}
return _errorMessageStyle;
}
}
///
/// Gets or sets the URL of an image to be displayed for the help link.
///
[
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.LoginControls_HelpPageIconUrl),
Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string HelpPageIconUrl {
get {
object obj = ViewState["HelpPageIconUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["HelpPageIconUrl"] = value;
}
}
///
/// Gets or sets the text to be shown for the help link.
///
[
Localizable(true),
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.ChangePassword_HelpPageText)
]
public virtual string HelpPageText {
get {
object obj = ViewState["HelpPageText"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["HelpPageText"] = value;
}
}
///
/// Gets or sets the URL of the help page.
///
[
WebCategory("Links"),
DefaultValue(""),
WebSysDescription(SR.LoginControls_HelpPageUrl),
Editor("System.Web.UI.Design.UrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty()
]
public virtual string HelpPageUrl {
get {
object obj = ViewState["HelpPageUrl"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["HelpPageUrl"] = value;
}
}
///
/// Gets the style of the hyperlinks.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.WebControl_HyperLinkStyle)
]
public TableItemStyle HyperLinkStyle {
get {
if (_hyperLinkStyle == null) {
_hyperLinkStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_hyperLinkStyle).TrackViewState();
}
}
return _hyperLinkStyle;
}
}
///
/// Gets or sets the text that is displayed to give instructions.
///
[
Localizable(true),
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.WebControl_InstructionText)
]
public virtual string InstructionText {
get {
object obj = ViewState["InstructionText"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["InstructionText"] = value;
}
}
///
/// Gets the style of the instructions.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.WebControl_InstructionTextStyle)
]
public TableItemStyle InstructionTextStyle {
get {
if (_instructionTextStyle == null) {
_instructionTextStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_instructionTextStyle).TrackViewState();
}
}
return _instructionTextStyle;
}
}
///
/// Gets or sets the message that is displayed for answer errors
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidAnswerErrorMessage),
WebSysDescription(SR.CreateUserWizard_InvalidAnswerErrorMessage)
]
public virtual string InvalidAnswerErrorMessage {
get {
object obj = ViewState["InvalidAnswerErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidAnswerErrorMessage) : (string)obj;
}
set {
ViewState["InvalidAnswerErrorMessage"] = value;
}
}
///
/// Gets or sets the message that is displayed for email errors
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidEmailErrorMessage),
WebSysDescription(SR.CreateUserWizard_InvalidEmailErrorMessage)
]
public virtual string InvalidEmailErrorMessage {
get {
object obj = ViewState["InvalidEmailErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidEmailErrorMessage) : (string)obj;
}
set {
ViewState["InvalidEmailErrorMessage"] = value;
}
}
///
/// Gets or sets the text to be shown there is a problem with the password.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidPasswordErrorMessage),
WebSysDescription(SR.CreateUserWizard_InvalidPasswordErrorMessage)
]
public virtual string InvalidPasswordErrorMessage {
get {
object obj = ViewState["InvalidPasswordErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidPasswordErrorMessage) : (string)obj;
}
set {
ViewState["InvalidPasswordErrorMessage"] = value;
}
}
///
/// Gets or sets the message that is displayed for question errors
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultInvalidQuestionErrorMessage),
WebSysDescription(SR.CreateUserWizard_InvalidQuestionErrorMessage)
]
public virtual string InvalidQuestionErrorMessage {
get {
object obj = ViewState["InvalidQuestionErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultInvalidQuestionErrorMessage) : (string)obj;
}
set {
ViewState["InvalidQuestionErrorMessage"] = value;
}
}
///
/// Gets the style of the textbox labels.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.LoginControls_LabelStyle)
]
public TableItemStyle LabelStyle {
get {
if (_labelStyle == null) {
_labelStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_labelStyle).TrackViewState();
}
}
return _labelStyle;
}
}
///
/// Gets or sets whether the created user will be logged into the site
///
[
WebCategory("Behavior"),
DefaultValue(true),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_LoginCreatedUser)
]
public virtual bool LoginCreatedUser {
get {
object obj = ViewState["LoginCreatedUser"];
return (obj == null) ? true : (bool)obj;
}
set {
ViewState["LoginCreatedUser"] = value;
}
}
///
/// The content and format of the e-mail message that contains the new password.
///
[
WebCategory("Behavior"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_MailDefinition)
]
public MailDefinition MailDefinition {
get {
if (_mailDefinition == null) {
_mailDefinition = new MailDefinition();
if (IsTrackingViewState) {
((IStateManager)_mailDefinition).TrackViewState();
}
}
return _mailDefinition;
}
}
///
/// Gets or sets the name of the membership provider. If null or empty, the default provider is used.
///
[
WebCategory("Data"),
DefaultValue(""),
Themeable(false),
WebSysDescription(SR.MembershipProvider_Name)
]
public virtual string MembershipProvider {
get {
object obj = ViewState["MembershipProvider"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
if (MembershipProvider != value) {
ViewState["MembershipProvider"] = value;
RequiresControlsRecreation();
}
}
}
///
/// Gets the new password entered by the user.
///
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public virtual string Password {
get {
return (_password == null) ? String.Empty : _password;
}
}
private string PasswordInternal {
get {
string password = Password;
if (String.IsNullOrEmpty(password) && !AutoGeneratePassword && _createUserStepContainer != null) {
ITextControl passwordTextBox = (ITextControl)_createUserStepContainer.PasswordTextBox;
if (passwordTextBox != null) {
return passwordTextBox.Text;
}
}
return password;
}
}
///
/// The style of the password hint text.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_PasswordHintStyle)
]
public TableItemStyle PasswordHintStyle {
get {
if (_passwordHintStyle == null) {
_passwordHintStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_passwordHintStyle).TrackViewState();
}
}
return _passwordHintStyle;
}
}
///
/// Gets or sets the text for the password hint.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(""),
WebSysDescription(SR.ChangePassword_PasswordHintText)
]
public virtual string PasswordHintText {
get {
object obj = ViewState["PasswordHintText"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["PasswordHintText"] = value;
}
}
///
/// Gets or sets the text that identifies the new password textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.LoginControls_DefaultPasswordLabelText),
WebSysDescription(SR.LoginControls_PasswordLabelText)
]
public virtual string PasswordLabelText {
get {
object obj = ViewState["PasswordLabelText"];
return (obj == null) ? SR.GetString(SR.LoginControls_DefaultPasswordLabelText) : (string)obj;
}
set {
ViewState["PasswordLabelText"] = value;
}
}
///
/// Regular expression used to validate the new password
///
[
WebCategory("Validation"),
WebSysDefaultValue(""),
WebSysDescription(SR.CreateUserWizard_PasswordRegularExpression)
]
public virtual string PasswordRegularExpression {
get {
object obj = ViewState["PasswordRegularExpression"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["PasswordRegularExpression"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the password fails the reg exp.
///
[
WebCategory("Validation"),
WebSysDefaultValue(SR.Password_InvalidPasswordErrorMessage),
WebSysDescription(SR.CreateUserWizard_PasswordRegularExpressionErrorMessage)
]
public virtual string PasswordRegularExpressionErrorMessage {
get {
object obj = ViewState["PasswordRegularExpressionErrorMessage"];
return (obj == null) ? SR.GetString(SR.Password_InvalidPasswordErrorMessage) : (string)obj;
}
set {
ViewState["PasswordRegularExpressionErrorMessage"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the new password is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultPasswordRequiredErrorMessage),
WebSysDescription(SR.CreateUserWizard_PasswordRequiredErrorMessage)
]
public virtual string PasswordRequiredErrorMessage {
get {
object obj = ViewState["PasswordRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultPasswordRequiredErrorMessage) : (string)obj;
}
set {
ViewState["PasswordRequiredErrorMessage"] = value;
}
}
///
/// Gets or sets the initial value in the question textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
DefaultValue(""),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_Question)
]
public virtual string Question {
get {
object obj = ViewState["Question"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["Question"] = value;
}
}
private string QuestionInternal {
get {
string question = Question;
if (String.IsNullOrEmpty(question) && _createUserStepContainer != null) {
ITextControl questionTextBox = (ITextControl)_createUserStepContainer.QuestionTextBox;
if (questionTextBox != null) {
question = questionTextBox.Text;
}
}
// Pass Null instead of Empty into Membership
if (String.IsNullOrEmpty(question)) question = null;
return question;
}
}
///
/// Gets whether an security question and answer is required to create the user
///
[
WebCategory("Validation"),
DefaultValue(true),
WebSysDescription(SR.CreateUserWizard_QuestionAndAnswerRequired)
]
protected internal bool QuestionAndAnswerRequired {
get {
if (DesignMode) {
// Don't require question and answer if the CreateUser step is templated in the designer
if (CreateUserStep != null && CreateUserStep.ContentTemplate != null) {
return false;
}
return true;
}
return LoginUtil.GetProvider(MembershipProvider).RequiresQuestionAndAnswer;
}
}
///
/// Gets or sets the text that identifies the question textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultQuestionLabelText),
WebSysDescription(SR.CreateUserWizard_QuestionLabelText)
]
public virtual string QuestionLabelText {
get {
object obj = ViewState["QuestionLabelText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultQuestionLabelText) : (string)obj;
}
set {
ViewState["QuestionLabelText"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the question is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultQuestionRequiredErrorMessage),
WebSysDescription(SR.CreateUserWizard_QuestionRequiredErrorMessage)
]
public virtual string QuestionRequiredErrorMessage {
get {
object obj = ViewState["QuestionRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultQuestionRequiredErrorMessage) : (string)obj;
}
set {
ViewState["QuestionRequiredErrorMessage"] = value;
}
}
///
/// Gets whether an email address is required to create the user
///
[
WebCategory("Behavior"),
DefaultValue(true),
Themeable(false),
WebSysDescription(SR.CreateUserWizard_RequireEmail)
]
public virtual bool RequireEmail {
get {
object obj = ViewState["RequireEmail"];
return (obj == null) ? true : (bool)obj;
}
set {
if (RequireEmail != value) {
ViewState["RequireEmail"] = value;
}
}
}
internal override bool ShowCustomNavigationTemplate {
get {
if (base.ShowCustomNavigationTemplate) return true;
return (ActiveStep == CreateUserStep);
}
}
[
DefaultValue(""),
]
public override string SkipLinkText {
get {
string s = SkipLinkTextInternal;
return s == null ? String.Empty : s;
}
set {
base.SkipLinkText = value;
}
}
///
/// Gets or sets the style of the textboxes.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.LoginControls_TextBoxStyle)
]
public Style TextBoxStyle {
get {
if (_textBoxStyle == null) {
_textBoxStyle = new Style();
if (IsTrackingViewState) {
((IStateManager)_textBoxStyle).TrackViewState();
}
}
return _textBoxStyle;
}
}
///
/// Gets the style of the title.
///
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.LoginControls_TitleTextStyle)
]
public TableItemStyle TitleTextStyle {
get {
if (_titleTextStyle == null) {
_titleTextStyle = new TableItemStyle();
if (IsTrackingViewState) {
((IStateManager)_titleTextStyle).TrackViewState();
}
}
return _titleTextStyle;
}
}
///
/// Gets or sets the initial value in the user name textbox.
///
[
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.UserName_InitialValue)
]
public virtual string UserName {
get {
object obj = ViewState["UserName"];
return (obj == null) ? String.Empty : (string)obj;
}
set {
ViewState["UserName"] = value;
}
}
private string UserNameInternal {
get {
string userName = UserName;
if (String.IsNullOrEmpty(userName) && _createUserStepContainer != null) {
ITextControl userNameTextBox = (ITextControl)_createUserStepContainer.UserNameTextBox;
if (userNameTextBox != null) {
return userNameTextBox.Text;
}
}
return userName;
}
}
///
/// Gets or sets the text that identifies the user name textbox.
///
[
Localizable(true),
WebCategory("Appearance"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultUserNameLabelText),
WebSysDescription(SR.LoginControls_UserNameLabelText)
]
public virtual string UserNameLabelText {
get {
object obj = ViewState["UserNameLabelText"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUserNameLabelText) : (string)obj;
}
set {
ViewState["UserNameLabelText"] = value;
}
}
///
/// Gets or sets the text to be shown in the validation summary when the user name is empty.
///
[
Localizable(true),
WebCategory("Validation"),
WebSysDefaultValue(SR.CreateUserWizard_DefaultUserNameRequiredErrorMessage),
WebSysDescription(SR.ChangePassword_UserNameRequiredErrorMessage)
]
public virtual string UserNameRequiredErrorMessage {
get {
object obj = ViewState["UserNameRequiredErrorMessage"];
return (obj == null) ? SR.GetString(SR.CreateUserWizard_DefaultUserNameRequiredErrorMessage) : (string)obj;
}
set {
ViewState["UserNameRequiredErrorMessage"] = value;
}
}
[
WebCategory("Styles"),
DefaultValue(null),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
WebSysDescription(SR.CreateUserWizard_ValidatorTextStyle)
]
public Style ValidatorTextStyle {
get {
if (_validatorTextStyle == null) {
_validatorTextStyle = new ErrorStyle();
if (IsTrackingViewState) {
((IStateManager)_validatorTextStyle).TrackViewState();
}
}
return _validatorTextStyle;
}
}
private string ValidationGroup {
get {
if (_validationGroup == null) {
EnsureID();
_validationGroup = ID;
}
return _validationGroup;
}
}
[
Editor("System.Web.UI.Design.WebControls.CreateUserWizardStepCollectionEditor," + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
]
public override WizardStepCollection WizardSteps {
get {
return base.WizardSteps;
}
}
#endregion
#region Public Events
///
/// Raised on the click of the continue button.
///
[
WebCategory("Action"),
WebSysDescription(SR.CreateUserWizard_ContinueButtonClick)
]
public event EventHandler ContinueButtonClick {
add {
Events.AddHandler(EventButtonContinueClick, value);
}
remove {
Events.RemoveHandler(EventButtonContinueClick, value);
}
}
///
/// Raised before a user is created.
///
[
WebCategory("Action"),
WebSysDescription(SR.CreateUserWizard_CreatingUser)
]
public event LoginCancelEventHandler CreatingUser {
add {
Events.AddHandler(EventCreatingUser, value);
}
remove {
Events.RemoveHandler(EventCreatingUser, value);
}
}
///
/// Raised after a user is created.
///
[
WebCategory("Action"),
WebSysDescription(SR.CreateUserWizard_CreatedUser)
]
public event EventHandler CreatedUser {
add {
Events.AddHandler(EventCreatedUser, value);
}
remove {
Events.RemoveHandler(EventCreatedUser, value);
}
}
///
/// Raised on a create user error
///
[
WebCategory("Action"),
WebSysDescription(SR.CreateUserWizard_CreateUserError)
]
public event CreateUserErrorEventHandler CreateUserError {
add {
Events.AddHandler(EventCreateUserError, value);
}
remove {
Events.RemoveHandler(EventCreateUserError, value);
}
}
///
/// Raised before the e-mail is sent.
///
[
WebCategory("Action"),
WebSysDescription(SR.ChangePassword_SendingMail)
]
public event MailMessageEventHandler SendingMail {
add {
Events.AddHandler(EventSendingMail, value);
}
remove {
Events.RemoveHandler(EventSendingMail, value);
}
}
///
/// Raised when there is an error sending mail.
///
[
WebCategory("Action"),
WebSysDescription(SR.CreateUserWizard_SendMailError)
]
public event SendMailErrorEventHandler SendMailError {
add {
Events.AddHandler(EventSendMailError, value);
}
remove {
Events.RemoveHandler(EventSendMailError, value);
}
}
#endregion
private void AnswerTextChanged(object source, EventArgs e) {
Answer = ((ITextControl)source).Text;
}
///
/// Sets the properties of child controls that are editable by the client.
///
private void ApplyCommonCreateUserValues() {
// We need to use Internal for the DropDownList case where it won't fire a TextChanged for the first item
if (!String.IsNullOrEmpty(UserNameInternal)) {
ITextControl userNameTextBox = (ITextControl)_createUserStepContainer.UserNameTextBox;
if (userNameTextBox != null) {
userNameTextBox.Text = UserNameInternal;
}
}
if (!String.IsNullOrEmpty(EmailInternal)) {
ITextControl emailTextBox = (ITextControl)_createUserStepContainer.EmailTextBox;
if (emailTextBox != null) {
emailTextBox.Text = EmailInternal;
}
}
if (!String.IsNullOrEmpty(QuestionInternal)) {
ITextControl questionTextBox = (ITextControl)_createUserStepContainer.QuestionTextBox;
if (questionTextBox != null) {
questionTextBox.Text = QuestionInternal;
}
}
if (!String.IsNullOrEmpty(AnswerInternal)) {
ITextControl answerTextBox = (ITextControl)_createUserStepContainer.AnswerTextBox;
if (answerTextBox != null) {
answerTextBox.Text = AnswerInternal;
}
}
}
private void ApplyDefaultCreateUserValues() {
_createUserStepContainer.UserNameLabel.Text = UserNameLabelText;
WebControl userTextBox = (WebControl)_createUserStepContainer.UserNameTextBox;
userTextBox.TabIndex = TabIndex;
userTextBox.AccessKey = AccessKey;
_createUserStepContainer.PasswordLabel.Text = PasswordLabelText;
WebControl passwordTextBox = (WebControl)_createUserStepContainer.PasswordTextBox;
passwordTextBox.TabIndex = TabIndex;
_createUserStepContainer.ConfirmPasswordLabel.Text = ConfirmPasswordLabelText;
WebControl confirmTextBox = (WebControl)_createUserStepContainer.ConfirmPasswordTextBox;
confirmTextBox.TabIndex = TabIndex;
if (_textBoxStyle != null) {
userTextBox.ApplyStyle(_textBoxStyle);
passwordTextBox.ApplyStyle(_textBoxStyle);
confirmTextBox.ApplyStyle(_textBoxStyle);
}
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.Title, CreateUserStep.Title, TitleTextStyle, true);
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.InstructionLabel, InstructionText, InstructionTextStyle, true);
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.UserNameLabel, UserNameLabelText, LabelStyle, false);
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.PasswordLabel, PasswordLabelText, LabelStyle, false);
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.ConfirmPasswordLabel, ConfirmPasswordLabelText, LabelStyle, false);
// VSWhidbey 447805 Do not render PasswordHintText if AutoGeneratePassword is false.
if (!String.IsNullOrEmpty(PasswordHintText) && !AutoGeneratePassword) {
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.PasswordHintLabel, PasswordHintText, PasswordHintStyle, false);
} else {
_passwordHintTableRow.Visible = false;
}
bool enableValidation = true;
WebControl emailTextBox = null;
if (RequireEmail) {
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.EmailLabel, EmailLabelText, LabelStyle, false);
emailTextBox = (WebControl)_createUserStepContainer.EmailTextBox;
((ITextControl)emailTextBox).Text = Email;
RequiredFieldValidator emailRequired = _createUserStepContainer.EmailRequired;
emailRequired.ToolTip = EmailRequiredErrorMessage;
emailRequired.ErrorMessage = EmailRequiredErrorMessage;
emailRequired.Enabled = enableValidation;
emailRequired.Visible = enableValidation;
if (_validatorTextStyle != null) {
emailRequired.ApplyStyle(_validatorTextStyle);
}
emailTextBox.TabIndex = TabIndex;
if (_textBoxStyle != null) {
emailTextBox.ApplyStyle(_textBoxStyle);
}
} else {
_emailRow.Visible = false;
}
WebControl questionTextBox = null;
WebControl answerTextBox = null;
RequiredFieldValidator questionRequired = _createUserStepContainer.QuestionRequired;
RequiredFieldValidator answerRequired = _createUserStepContainer.AnswerRequired;
bool qaValidatorsEnabled = enableValidation && QuestionAndAnswerRequired;
questionRequired.Enabled = qaValidatorsEnabled;
questionRequired.Visible = qaValidatorsEnabled;
answerRequired.Enabled = qaValidatorsEnabled;
answerRequired.Visible = qaValidatorsEnabled;
if (QuestionAndAnswerRequired) {
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.QuestionLabel, QuestionLabelText, LabelStyle, false);
questionTextBox = (WebControl)_createUserStepContainer.QuestionTextBox;
((ITextControl)questionTextBox).Text = Question;
questionTextBox.TabIndex = TabIndex;
LoginUtil.ApplyStyleToLiteral(_createUserStepContainer.AnswerLabel, AnswerLabelText, LabelStyle, false);
answerTextBox = (WebControl)_createUserStepContainer.AnswerTextBox;
((ITextControl)answerTextBox).Text = Answer;
answerTextBox.TabIndex = TabIndex;
if (_textBoxStyle != null) {
questionTextBox.ApplyStyle(_textBoxStyle);
answerTextBox.ApplyStyle(_textBoxStyle);
}
questionRequired.ToolTip = QuestionRequiredErrorMessage;
questionRequired.ErrorMessage = QuestionRequiredErrorMessage;
answerRequired.ToolTip = AnswerRequiredErrorMessage;
answerRequired.ErrorMessage = AnswerRequiredErrorMessage;
if (_validatorTextStyle != null) {
questionRequired.ApplyStyle(_validatorTextStyle);
answerRequired.ApplyStyle(_validatorTextStyle);
}
} else {
_questionRow.Visible = false;
_answerRow.Visible = false;
}
if (_defaultCreateUserNavigationTemplate != null) {
((BaseNavigationTemplateContainer)(CreateUserStep.CustomNavigationTemplateContainer)).NextButton = _defaultCreateUserNavigationTemplate.CreateUserButton;
((BaseNavigationTemplateContainer)(CreateUserStep.CustomNavigationTemplateContainer)).CancelButton = _defaultCreateUserNavigationTemplate.CancelButton;
}
RequiredFieldValidator passwordRequired = _createUserStepContainer.PasswordRequired;
RequiredFieldValidator confirmPasswordRequired = _createUserStepContainer.ConfirmPasswordRequired;
CompareValidator passwordCompareValidator = _createUserStepContainer.PasswordCompareValidator;
RegularExpressionValidator regExpValidator = _createUserStepContainer.PasswordRegExpValidator;
bool passwordValidatorsEnabled = enableValidation && !AutoGeneratePassword;
passwordRequired.Enabled = passwordValidatorsEnabled;
passwordRequired.Visible = passwordValidatorsEnabled;
confirmPasswordRequired.Enabled = passwordValidatorsEnabled;
confirmPasswordRequired.Visible = passwordValidatorsEnabled;
passwordCompareValidator.Enabled = passwordValidatorsEnabled;
passwordCompareValidator.Visible = passwordValidatorsEnabled;
bool passRegExpEnabled = passwordValidatorsEnabled && PasswordRegularExpression.Length > 0;
regExpValidator.Enabled = passRegExpEnabled;
regExpValidator.Visible = passRegExpEnabled;
if (!enableValidation) {
_passwordRegExpRow.Visible = false;
_passwordCompareRow.Visible = false;
_emailRegExpRow.Visible = false;
}
if (AutoGeneratePassword) {
_passwordTableRow.Visible = false;
_confirmPasswordTableRow.Visible = false;
_passwordRegExpRow.Visible = false;
_passwordCompareRow.Visible = false;
} else {
passwordRequired.ErrorMessage = PasswordRequiredErrorMessage;
passwordRequired.ToolTip = PasswordRequiredErrorMessage;
confirmPasswordRequired.ErrorMessage = ConfirmPasswordRequiredErrorMessage;
confirmPasswordRequired.ToolTip = ConfirmPasswordRequiredErrorMessage;
passwordCompareValidator.ErrorMessage = ConfirmPasswordCompareErrorMessage;
if (_validatorTextStyle != null) {
passwordRequired.ApplyStyle(_validatorTextStyle);
confirmPasswordRequired.ApplyStyle(_validatorTextStyle);
passwordCompareValidator.ApplyStyle(_validatorTextStyle);
}
if (passRegExpEnabled) {
regExpValidator.ValidationExpression = PasswordRegularExpression;
regExpValidator.ErrorMessage = PasswordRegularExpressionErrorMessage;
if (_validatorTextStyle != null) {
regExpValidator.ApplyStyle(_validatorTextStyle);
}
} else {
_passwordRegExpRow.Visible = false;
}
}
RequiredFieldValidator userNameRequired = _createUserStepContainer.UserNameRequired;
userNameRequired.ErrorMessage = UserNameRequiredErrorMessage;
userNameRequired.ToolTip = UserNameRequiredErrorMessage;
userNameRequired.Enabled = enableValidation;
userNameRequired.Visible = enableValidation;
if (_validatorTextStyle != null) {
userNameRequired.ApplyStyle(_validatorTextStyle);
}
bool emailRegExpEnabled = enableValidation && EmailRegularExpression.Length > 0 && RequireEmail;
RegularExpressionValidator emailRegExpValidator = _createUserStepContainer.EmailRegExpValidator;
emailRegExpValidator.Enabled = emailRegExpEnabled;
emailRegExpValidator.Visible = emailRegExpEnabled;
if (EmailRegularExpression.Length > 0 && RequireEmail) {
emailRegExpValidator.ValidationExpression = EmailRegularExpression;
emailRegExpValidator.ErrorMessage = EmailRegularExpressionErrorMessage;
if (_validatorTextStyle != null) {
emailRegExpValidator.ApplyStyle(_validatorTextStyle);
}
} else {
_emailRegExpRow.Visible = false;
}
// Link Setup
string helpPageText = HelpPageText;
bool helpPageTextVisible = (helpPageText.Length > 0);
HyperLink helpPageLink = _createUserStepContainer.HelpPageLink;
Image helpPageIcon = _createUserStepContainer.HelpPageIcon;
helpPageLink.Visible = helpPageTextVisible;
if (helpPageTextVisible) {
helpPageLink.Text = helpPageText;
helpPageLink.NavigateUrl = HelpPageUrl;
helpPageLink.TabIndex = TabIndex;
}
string helpPageIconUrl = HelpPageIconUrl;
bool helpPageIconVisible = (helpPageIconUrl.Length > 0);
helpPageIcon.Visible = helpPageIconVisible;
if (helpPageIconVisible) {
helpPageIcon.ImageUrl = helpPageIconUrl;
helpPageIcon.AlternateText = helpPageText;
}
LoginUtil.SetTableCellVisible(helpPageLink, helpPageTextVisible || helpPageIconVisible);
if (_hyperLinkStyle != null && (helpPageTextVisible || helpPageIconVisible)) {
// Apply style except font to table cell, then apply font and forecolor to HyperLinks
// VSWhidbey 81289
TableItemStyle hyperLinkStyleExceptFont = new TableItemStyle();
hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
hyperLinkStyleExceptFont.Font.Reset();
LoginUtil.SetTableCellStyle(helpPageLink, hyperLinkStyleExceptFont);
helpPageLink.Font.CopyFrom(_hyperLinkStyle.Font);
helpPageLink.ForeColor = _hyperLinkStyle.ForeColor;
}
Control errorMessageLabel = _createUserStepContainer.ErrorMessageLabel;
if (errorMessageLabel != null) {
if (_failure && !String.IsNullOrEmpty(_unknownErrorMessage)) {
((ITextControl)errorMessageLabel).Text = _unknownErrorMessage;
LoginUtil.SetTableCellStyle(errorMessageLabel, ErrorMessageStyle);
LoginUtil.SetTableCellVisible(errorMessageLabel, true);
} else {
LoginUtil.SetTableCellVisible(errorMessageLabel, false);
}
}
}
private void ApplyCompleteValues() {
LoginUtil.ApplyStyleToLiteral(_completeStepContainer.SuccessTextLabel, CompleteSuccessText, _completeSuccessTextStyle, true);
switch (ContinueButtonType) {
case ButtonType.Link:
_completeStepContainer.ContinuePushButton.Visible = false;
_completeStepContainer.ContinueImageButton.Visible = false;
_completeStepContainer.ContinueLinkButton.Text = ContinueButtonText;
_completeStepContainer.ContinueLinkButton.ValidationGroup = ValidationGroup;
_completeStepContainer.ContinueLinkButton.TabIndex = TabIndex;
_completeStepContainer.ContinueLinkButton.AccessKey = AccessKey;
break;
case ButtonType.Button:
_completeStepContainer.ContinueLinkButton.Visible = false;
_completeStepContainer.ContinueImageButton.Visible = false;
_completeStepContainer.ContinuePushButton.Text = ContinueButtonText;
_completeStepContainer.ContinuePushButton.ValidationGroup = ValidationGroup;
_completeStepContainer.ContinuePushButton.TabIndex = TabIndex;
_completeStepContainer.ContinuePushButton.AccessKey = AccessKey;
break;
case ButtonType.Image:
_completeStepContainer.ContinueLinkButton.Visible = false;
_completeStepContainer.ContinuePushButton.Visible = false;
_completeStepContainer.ContinueImageButton.ImageUrl = ContinueButtonImageUrl;
_completeStepContainer.ContinueImageButton.AlternateText = ContinueButtonText;
_completeStepContainer.ContinueImageButton.ValidationGroup = ValidationGroup;
_completeStepContainer.ContinueImageButton.TabIndex = TabIndex;
_completeStepContainer.ContinueImageButton.AccessKey = AccessKey;
break;
}
if (!NavigationButtonStyle.IsEmpty) {
_completeStepContainer.ContinuePushButton.ApplyStyle(NavigationButtonStyle);
_completeStepContainer.ContinueImageButton.ApplyStyle(NavigationButtonStyle);
_completeStepContainer.ContinueLinkButton.ApplyStyle(NavigationButtonStyle);
}
if (_continueButtonStyle != null) {
_completeStepContainer.ContinuePushButton.ApplyStyle(_continueButtonStyle);
_completeStepContainer.ContinueImageButton.ApplyStyle(_continueButtonStyle);
_completeStepContainer.ContinueLinkButton.ApplyStyle(_continueButtonStyle);
}
LoginUtil.ApplyStyleToLiteral(_completeStepContainer.Title, CompleteStep.Title, _titleTextStyle, true);
string editProfileText = EditProfileText;
bool editProfileVisible = (editProfileText.Length > 0);
HyperLink editProfileLink = _completeStepContainer.EditProfileLink;
editProfileLink.Visible = editProfileVisible;
if (editProfileVisible) {
editProfileLink.Text = editProfileText;
editProfileLink.NavigateUrl = EditProfileUrl;
editProfileLink.TabIndex = TabIndex;
if (_hyperLinkStyle != null) {
// Apply style except font to table cell, then apply font and forecolor to HyperLinks
// VSWhidbey 81289
Style hyperLinkStyleExceptFont = new TableItemStyle();
hyperLinkStyleExceptFont.CopyFrom(_hyperLinkStyle);
hyperLinkStyleExceptFont.Font.Reset();
LoginUtil.SetTableCellStyle(editProfileLink, hyperLinkStyleExceptFont);
editProfileLink.Font.CopyFrom(_hyperLinkStyle.Font);
editProfileLink.ForeColor = _hyperLinkStyle.ForeColor;
}
}
string editProfileIconUrl = EditProfileIconUrl;
bool editProfileIconVisible = (editProfileIconUrl.Length > 0);
Image editProfileIcon = _completeStepContainer.EditProfileIcon;
editProfileIcon.Visible = editProfileIconVisible;
if (editProfileIconVisible) {
editProfileIcon.ImageUrl = editProfileIconUrl;
editProfileIcon.AlternateText = EditProfileText;
}
LoginUtil.SetTableCellVisible(editProfileLink, editProfileVisible || editProfileIconVisible);
// Copy the styles from the StepStyle property if defined.
Table table = ((CompleteStepContainer)(CompleteStep.ContentTemplateContainer)).LayoutTable;
table.Height = Height;
table.Width = Width;
}
///
/// Attempts to create a user, returns false if unsuccessful
///
private bool AttemptCreateUser() {
if (Page != null && !Page.IsValid) {
return false;
}
LoginCancelEventArgs args = new LoginCancelEventArgs();
OnCreatingUser(args);
if (args.Cancel) return false;
MembershipProvider provider = LoginUtil.GetProvider(MembershipProvider);
MembershipCreateStatus status;
if (AutoGeneratePassword) {
int length = Math.Max(10, Membership.MinRequiredPasswordLength);
_password = Membership.GeneratePassword(length, Membership.MinRequiredNonAlphanumericCharacters);
}
// CreateUser() should not throw an exception. Status is returned through the out parameter.
provider.CreateUser(UserNameInternal, PasswordInternal, EmailInternal, QuestionInternal, AnswerInternal, !DisableCreatedUser /*isApproved*/, null, out status);
if (status == MembershipCreateStatus.Success) {
OnCreatedUser(EventArgs.Empty);
// Send mail if specified
if (_mailDefinition != null && !String.IsNullOrEmpty(EmailInternal)) {
LoginUtil.SendPasswordMail(EmailInternal, UserNameInternal, PasswordInternal, MailDefinition,
/*defaultSubject*/ null, /*defaultBody*/ null, OnSendingMail, OnSendMailError,
this);
}
// Set AllowReturn to false now that we've created the user
CreateUserStep.AllowReturnInternal = false;
// Set the logged in cookie if required
if (LoginCreatedUser) {
AttemptLogin();
}
return true;
} else {
// Failed to create user handling below.
// Raise the error first so users get a chance to change the failure text.
OnCreateUserError(new CreateUserErrorEventArgs(status));
switch (status) {
case MembershipCreateStatus.DuplicateEmail:
_unknownErrorMessage = DuplicateEmailErrorMessage;
break;
case MembershipCreateStatus.DuplicateUserName:
_unknownErrorMessage = DuplicateUserNameErrorMessage;
break;
case MembershipCreateStatus.InvalidAnswer:
_unknownErrorMessage = InvalidAnswerErrorMessage;
break;
case MembershipCreateStatus.InvalidEmail:
_unknownErrorMessage = InvalidEmailErrorMessage;
break;
case MembershipCreateStatus.InvalidQuestion:
_unknownErrorMessage = InvalidQuestionErrorMessage;
break;
case MembershipCreateStatus.InvalidPassword:
string invalidPasswordErrorMessage = InvalidPasswordErrorMessage;
if (!String.IsNullOrEmpty(invalidPasswordErrorMessage)) {
invalidPasswordErrorMessage = String.Format(CultureInfo.InvariantCulture, invalidPasswordErrorMessage,
provider.MinRequiredPasswordLength, provider.MinRequiredNonAlphanumericCharacters);
}
_unknownErrorMessage = invalidPasswordErrorMessage;
break;
default:
_unknownErrorMessage = UnknownErrorMessage;
break;
}
return false;
}
}
private void AttemptLogin() {
// Try to authenticate the user
MembershipProvider provider = LoginUtil.GetProvider(MembershipProvider);
// ValidateUser() should not throw an exception.
if (provider.ValidateUser(UserName, Password)) {
System.Web.Security.FormsAuthentication.SetAuthCookie(UserNameInternal, false);
}
}
private void ConfirmPasswordTextChanged(object source, EventArgs e) {
if (!AutoGeneratePassword) {
_confirmPassword = ((ITextControl)source).Text;
}
}
///
///
///
protected internal override void CreateChildControls() {
_createUserStep = null;
_completeStep = null;
base.CreateChildControls();
UpdateValidators();
}
private void RegisterEvents() {
RegisterTextChangedEvent(_createUserStepContainer.UserNameTextBox, UserNameTextChanged);
RegisterTextChangedEvent(_createUserStepContainer.EmailTextBox, EmailTextChanged);
RegisterTextChangedEvent(_createUserStepContainer.QuestionTextBox, QuestionTextChanged);
RegisterTextChangedEvent(_createUserStepContainer.AnswerTextBox, AnswerTextChanged);
RegisterTextChangedEvent(_createUserStepContainer.PasswordTextBox, PasswordTextChanged);
RegisterTextChangedEvent(_createUserStepContainer.ConfirmPasswordTextBox, ConfirmPasswordTextChanged);
}
private static void RegisterTextChangedEvent(Control control, Action