troubleshooting Question

Error customizing CreateUserWizard control

Avatar of derrekdeveloper
derrekdeveloperFlag for United States of America asked on
3 Comments2 Solutions315 ViewsLast Modified:
In the following code I am recieving these errors. I am atemmpting to do the impossible as it seems now and that is gather additiaonal user data while creating a new user utilizing the CreateUserWizard control. I was able to locate the following code and I think my process will work if I can correct these errors. I have place arrows where I have the bad syntax or code. Can anyone tell me how or what I should change the code to. Please provide the full code or syntax if you can help. Thanks in advance.

1. 'ProviderUserKey' is not a member of 'System.Web.Security.Membership'

2. 'System.Web.Security.MembershipUser' cannot be converted to 'System.Web.Security.Membership'

Partial Class registration
    Inherits System.Web.UI.Page
    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles CreateUserWizard1.CreatedUser
        ' Get the UserId of the just-added user
---->  Dim newUser As Membership = Membership.GetUser(CreateUserWizard1.UserName)
---->   Dim newUserId As Guid = DirectCast(newUser.ProviderUserKey, Guid)

        'Get Profile Data Entered by user in CUW control

        Dim FirstName As String = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"), TextBox).Text
        Dim LastName As String = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName"), TextBox).Text

        ' Insert a new record into User_Profile

        ' Get your Connection String from the web.config. MembershipConnectionString is the name I have in my web.config
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("MembershipConnectionString").ConnectionString

        Dim insertSql As String = "INSERT INTO User_Profile(UserId,FirstName, LastName) VALUES(@UserId, @FirstName, @LastName)"
        Using myConnection As New Data.SqlClient.SqlConnection(connectionString)
            Dim myCommand As New Data.SqlClient.SqlCommand(insertSql, myConnection)
            myCommand.Parameters.AddWithValue("@UserId", newUserId)
            myCommand.Parameters.AddWithValue("@FirstName", FirstName)
            myCommand.Parameters.AddWithValue("@LastName", LastName)

        End Using
    End Sub


End Class

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros