首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CreateUserWizard不会触发CompleteWizardStep

CreateUserWizard不会触发CompleteWizardStep
EN

Stack Overflow用户
提问于 2011-06-17 02:36:33
回答 1查看 876关注 0票数 0

我有一个自定义的CreateUserWizard,其中用户给他的电子邮件作为用户名。这段代码不会触发CompleteWizardStep1。我收到了成功消息,但成员资格模板仍处于活动状态,并且继续操作只会尝试创建另一个用户。

代码语言:javascript
复制
<fieldset>
        <legend>Create a User Account</legend>
        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" AutoGeneratePassword="False" 
             BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px" 
            CancelDestinationPageUrl="~/" ContinueDestinationPageUrl="~/CustomerDetails.aspx" 
            CreateUserButtonText="Continue" Font-Names="Verdana" Font-Size="0.8em" 
            OnCreatingUser="CreateUserWizard1_CreatingUser">
            <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" 
                VerticalAlign="Top" />
            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                ForeColor="#284775" />
            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                ForeColor="#284775" />
            <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" 
                Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" />
            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                ForeColor="#284775" />
            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <StepStyle BorderWidth="0px" />
            <WizardSteps>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" >
                   <ContentTemplate>
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Email Address:</asp:Label><br />
                            <asp:TextBox ID="UserName" runat="server" MaxLength="32"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" EnableClientScript="true"
                            ErrorMessage="Email address is required." ToolTip="Email address is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="regEmail" ControlToValidate="UserName" Text="Invalid e-mail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Runat="server" /><br />                
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label><br />
                            <asp:TextBox ID="Password" runat="server" TextMode="Password" 
                            MaxLength="16"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" EnableClientScript="true"
                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator><br />
                        <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label><br />
                            <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" 
                            MaxLength="16"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword" EnableClientScript="true"
                            ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator><br />
                            <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                            ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                            ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                        <asp:TextBox ID="Email" runat="server" Visible="false" MaxLength="1"></asp:TextBox>
                    </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" >
                </asp:CompleteWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>
        <p align="center">      
            <asp:Label ID="ActionStatus" runat="server" CssClass="Important"></asp:Label> 
        </p>
    </fieldset>

 protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
{
        Page.Validate("CreateUserWizard1");
        if (!Page.IsValid)
        {
            return;
        }
        CreateUserWizard cuw = (CreateUserWizard)sender;
        cuw.Email = cuw.UserName;

        // Make sure that the user doesn't already belong to this role      
        if (Roles.IsUserInRole(cuw.UserName, "Customers"))
        {
            ActionStatus.Text = string.Format("User {0} already is a member.", cuw.UserName);
            return;
        }

        Roles.AddUserToRole(cuw.UserName, "Customers");

        // Display a status message      
        ActionStatus.Text = string.Format("User {0} was added.", cuw.UserName);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-18 07:08:23

我很高兴没有人浪费他们的时间去尝试我的代码。

结果是需要出现在我的AspNetSqlMembershipProvider中的是requiresUniqueEmail="false“。它被设置为"true“,并且代码从未越过它。

感谢您的访问,并为您的意图干杯。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6376863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档