Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ast35 23 posts 44 karma points
    Oct 18, 2012 @ 14:44
    Ast35
    0

    Setting Member properties from ASP.NET user control using CreateUserWizard control

    OK, I've created a macro with an ASP.NET user control which creates a user and adds that user to a group (which is passed as a macro parameter).

    The thing is, I have discovered that the registration form needs to have additional fields. I've added several new member properties in Umbraco, but I can't work out how to access them from the user control.

    As ever, I'd appreciate any help with this.

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


            Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
            Roles.AddUserToRole(CreateUserWizard1.UserName, MemberGroup)
            Response.Redirect("/")


        End Sub
    End Class

  • Ast35 23 posts 44 karma points
    Oct 19, 2012 @ 17:16
    Ast35
    1

    Never mind, I figured it out myself.

    I needed to use the Umbraco Member object instead of the ASP.NET MembershipUser object.

    If anybody else comes looking for this information,in order to use the Umbraco API in a Visual Studio project, you have to copy businesslogic.dll, cms.dll, and umbraco.dll from the Umbraco bin directory to the bin directory of the project with your user control with the CreateUserWizard control in it, and add references to those files in your Visual Studio project.

    Here's what I did -

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

            ' The following four lines create TextBox objects for the TextBoxes in the customized CreateUserWizard ContentTemplate -

            Dim TitleTextBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Title"), TextBox)
            Dim FirstNameTextBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"), TextBox)
            Dim LastNameTextBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName"), TextBox)
            Dim JobTitleTextBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("JobTitle"), TextBox)

            ' Gets the member details based on the UserName
            Dim registeredMember As Member = Member.GetMemberFromLoginName(CreateUserWizard1.UserName)

     

            ' Use the getProperty method to set the custom member properties.

            registeredMember.getProperty("firstName").Value = FirstNameTextBox.Text
            registeredMember.getProperty("lastName").Value = LastNameTextBox.Text
            registeredMember.getProperty("jobTitle").Value = JobTitleTextBox.Text

            registeredMember.Save()

        End Sub

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 19, 2012 @ 18:19
    Tom Fulton
    0

    Hi,

    Thanks for posting your findings!

    If you're interested in an alternate method, check out this blog post:  http://www.aaron-powell.com/umbraco-members-profiles

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft