Link to home
Start Free TrialLog in
Avatar of jordanking
jordankingFlag for Canada

asked on

problem with Assigning Profile and Role values during createduser event of createuserwizard

Hello,

I have a create user wizard in an asp.net website.  I added the following code to the createduser event of the wizard:

but the line: "CreateUserWizard1.UserName.ToString" returns empty strings every time.  But in another website i have built this code works perfectly.  I can not figure out why this will not produce the username here.

thanks

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

        Dim RegentDB As New RegentSignsDataContext
        Dim intError As Integer
        Dim intCompID As Integer
        Dim RGTProfile As ProfileCommon = ProfileCommon.Create(CreateUserWizard1.UserName.ToString, True)

        ''assign profile values
        Dim CustCompID = RegentDB.RGT_Customer_COMPID(hfCustID.Value, intCompID)
        RGTProfile.intCompanyID = intCompID
        RGTProfile.intCustomerID = hfCustID.Value
        RGTProfile.Email = CreateUserWizard1.Email
        RGTProfile.FullName = hfFirstName.Value + " " + hfLastName.Value
        RGTProfile.OldUserID = hfOldUserID.Value
        ''save profile
        RGTProfile.Save()

        ''assign role membership
        Dim chrUser As String
        chrUser = CreateUserWizard1.UserName.ToString
        If hfAdmin.Value = "YY" Then
            Roles.AddUserToRole("kingnolan", "RgtAdmin")
        ElseIf hfManager.Value = "y" Then
            Roles.AddUserToRole(chrUser, "ErManager")
        Else
            Roles.AddUserToRole(chrUser, "Erequest")
        End If

        ''update RgtTable user to be activated = 1
        Dim CustActivated = RegentDB.RGT_User_ACTIVATED(hfCustID.Value, intError)

    End Sub

Open in new window

Avatar of Jesus Rodriguez
Jesus Rodriguez
Flag of United States of America image

An if you get the Usernae from RGTProfile?? Get an empty string too??
Avatar of jordanking

ASKER

RGTPRofile is not being created properly because there is no username being passed to its arguments "ProfileCommon.Create(username, isAuthenticated)", so it does not create a profile object and therefore has no username information.

The code i have work in another project I have, but something is not working in this specific situation.
so I am narrowing down the issue, but still no solution.  The create user wizard has the following fields:  username, password, confirm password, email, security question, and answer.  The email and username fields are set programically in the page load event as follows:

Dim tbUserName = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)
                tbUserName.Text = customer.chrUser

the "customer.chrUser" is from a recordset.field object that gets its information from sql server via LINQ.

As a result, the field values in the create user wizard that I set in the page load event are providing empty strings to the createdUser event.  The other fields that the user completes (ie password, security question, and answer) all work.

Therefore
CreateUserWizard1.UserName = "" an empty string
but
CreateUserWizard1.Question, CreateUserWizard1.Answer, CreateUserWizard1.Password all work and give the string value from the associated text boxes in the wizard


i can't figure out why this is hapening
ASKER CERTIFIED SOLUTION
Avatar of jordanking
jordanking
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial