用户是用一个标准的标准成员供应商创建的。
我试图追捕会员资格和例外,在我辩论守则时,我确实掌握了信息的方法。 我把这些财产放在创建UserWizardControl上,但当该页落空时,就显示出了缺省值,而不是我刚才确定的(tom)电文。
我的辛勤工作只是一个步骤,但我真的想知道我做什么错了。 我花了一天多时间,试图让这一令人izar笑.的行为发生。
寻找某种帮助或指导。
Thanks, Adam
<asp:CreateUserWizard ID="createUserWizard" runat="server"
ContinueDestinationPageUrl="/user/profile/"
CreateUserButtonText="Continue" RequireEmail="False" ActiveStepIndex="0">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" Title="Account details">
<ContentTemplate>
<fieldset>
<legend>Account details</legend>
<div>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Desired username:</asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Desired password:</asp:Label>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequiredValidator" runat="server" ControlToValidate="Password"
Display="Dynamic" EnableClientScript="false" ValidationGroup="createUserWizard">*</asp:RequiredFieldValidator>
</div>
<div>
<asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm password:</asp:Label>
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password"></asp:TextBox>
</div>
</fieldset>
<div class="errors">
<asp:ValidationSummary runat="server" ID="validationSummary"
DisplayMode="BulletList" ValidationGroup="createUserWizard"
HeaderText="<b>Please correct the following fields:</b>"
ShowMessageBox="False" ShowSummary="true" />
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="false" />
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
这里的编号(利益部分):
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
createUserWizard.CreatedUser += OnUserCreated;
createUserWizard.CreateUserError += OnError;
createUserWizard.NextButtonClick += OnNextButtonClick;
}
protected void OnUserCreated(object sender, EventArgs e)
{
//Add user to group and redirect to destination page.
}
private void OnNextButtonClick(object sender, WizardNavigationEventArgs e)
{
CreateUserWizard wizard = sender as CreateUserWizard;
if (wizard.ActiveStepIndex == 0)
{
try
{
if (Membership.ValidateUser(createUserWizard.UserName, createUserWizard.Password))
{
MembershipUser newUser = Membership.CreateUser(
createUserWizard.UserName,
createUserWizard.Password);
//add user to group and redirect to destination page
}
}
catch (MembershipCreateUserException ex)
{
SetFailureMessage(ex.StatusCode);
e.Cancel = true;
}
}
}
public void SetFailureMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
createUserWizard.DuplicateUserNameErrorMessage = "Username is not available."; //the string is fetched from a database.
break;
case MembershipCreateStatus.InvalidPassword:
createUserWizard.InvalidPasswordErrorMessage = "Password is not secure enough"; //the string is fetched from a database.
...
}
}
private void OnError(object sender, CreateUserErrorEventArgs e)
{
if (e.CreateUserError == MembershipCreateStatus.InvalidPassword)
{
CreateUserWizard wizard = sender as CreateUserWizard;
wizard.InvalidPasswordErrorMessage = "Password is not secure enough"; //the string is fetched from a database.
...
}
}