Quantcast
Viewing all articles
Browse latest Browse all 3509

CreateUserWizard creates correct new user plus a user named "User Name"

I don't have a clue as to what is happening here.  I'm using the CreateUserWizard to create new users and mostly it works but for every new user it adds it tries to add a user named "User Name" (in addition to the user I'm adding) and therefore always gives a status of the username already exists.  I'm hoping someone can look at the code and see where the problem is.  I'm using Visual Web Developer 2010 Express, VB.  Hopefully its something small that I'm not seeing :).  Thanks!

The VB portion:

Partial Class NewUsers
    Inherits System.Web.UI.Page
    Dim newUser As MembershipUser

    Protected Sub CreateUserWizard1_CancelButtonClick(sender As Object, e As System.EventArgs) Handles CreateUserWizard1.CancelButtonClick
        Response.Redirect("Main.aspx")
    End Sub


    Protected Sub CreateUserWizard1_CreatedUser(sender As Object, e As System.EventArgs) Handles CreateUserWizard1.CreatedUser

        Dim createStatus As MembershipCreateStatus
        newUser = Membership.CreateUser(CreateUserWizard1.UserNameLabelText, CreateUserWizard1.PasswordLabelText, CreateUserWizard1.EmailLabelText, "What is your favorite color?", CreateUserWizard1.QuestionLabelText, True, createStatus)

        Select Case createStatus
            Case MembershipCreateStatus.Success
                CreateUserWizard1.CompleteSuccessText = "The user account was successfully created!"
            Case MembershipCreateStatus.DuplicateUserName
                CreateUserWizard1.CompleteSuccessText = "That username already exists."
            Case MembershipCreateStatus.DuplicateEmail
                CreateUserWizard1.CompleteSuccessText = "A user with that Email address already exists."
            Case MembershipCreateStatus.InvalidEmail
                CreateUserWizard1.CompleteSuccessText = "PLease enter a VALID email address."
            Case MembershipCreateStatus.InvalidAnswer
                CreateUserWizard1.CompleteSuccessText = "The security answer is not valid"
            Case MembershipCreateStatus.InvalidPassword
                CreateUserWizard1.CompleteSuccessText = "The password entered is invalid. PLease enter a password with at least 7 cahacters and one non-alphanumeric."
            Case Else
                CreateUserWizard1.CompleteSuccessText = "Unknown Error: Account NOT created."
        End Select

    End Sub

    Protected Sub CreateUserWizard1_ContinueButtonClick(sender As Object, e As System.EventArgs) Handles CreateUserWizard1.ContinueButtonClick
        Response.Redirect("Main.aspx")
    End Sub

End Class

And the ASP portion:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewUsers.aspx.vb" Inherits="NewUsers" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title></head><body><form id="form1" runat="server" autocomplete="off"
    style="font-family: 'Arial Black'; font-size: medium"><div></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEW USER 
    SET-UP:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    Select Role<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"><asp:ListItem></asp:ListItem><asp:ListItem>Admin</asp:ListItem><asp:ListItem>Read Only</asp:ListItem><asp:ListItem>Update with Delete</asp:ListItem><asp:ListItem>Update without Delete</asp:ListItem><asp:ListItem>View Only</asp:ListItem></asp:DropDownList><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial Black" 
        Font-Size="Large" ForeColor="Red" 
        Text="You MUST select a Role for this user!"></asp:Label><asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3" 
        BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px" 
        DisplayCancelButton="True" Font-Names="Verdana" Font-Size="0.8em" 
        LoginCreatedUser="False" style="margin-left: 215px" Width="427px"><ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
            ForeColor="#284775" /><CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
            ForeColor="#284775" /><TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><WizardSteps><asp:CreateUserWizardStep runat="server" /><asp:CompleteWizardStep runat="server" /></WizardSteps><HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" 
            Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" /><NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
            ForeColor="#284775" /><SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" /><SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" 
            VerticalAlign="Top" /><StepStyle BorderWidth="0px" /></asp:CreateUserWizard></form></body></html>


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>