Copied to clipboard

Flag this post as spam?

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


  • ds 191 posts 223 karma points
    Jan 08, 2011 @ 22:59
    ds
    0

    How to save custom property into Member Type?

    Hi all,

    I am trying to extend asp.net membership sytem but I have to admit that I have not much experience for it so need a bit guidance.

    I created registration form using usercontrol and added some fields for collectiong more extra data like phone number as (Textbox), work type as (DropDownList).

    I also created Member Type and added some property phone number as (textstring), work type as (Dropdown Multiple), also added property to web.config file.

    After successfully creating user, I am able to see phone number on admin backend but not Work Type.

    My question is;

    1) Is this the right approach to collect user data using usercontrol? If it is, how is work type displayed after creating user on admin backend?

    2) Is there better way to collect extra data from user and save it to umbraco on member section?

    Here is my code;

     

            protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {

    TextBox UserName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName");

    DropDownList sector = (DropDownList)CreateUserWizardStep0.FindControl("Sector");
    ListBox WorkType = (ListBox)CreateUserWizardStep0.FindControl("WorkType");

    Roles.AddUserToRole(UserName.Text, "BasicUsers");
    var profile = System.Web.Profile.ProfileBase.Create(UserName.Text);
    profile["phone"] = phone.Text;
    profile["workType"] = WorkType.SelectedItem.Text;
    profile.Save();
    }

     Thanx,

    ds

  • Jason P. Brown 8 posts 28 karma points
    Mar 10, 2011 @ 17:37
    Jason P. Brown
    0

    Did you ever find a solution to this?

    I'm desperately looking for a good way to save and retrieve data to membertype properties and I'm very irked at the lack of unified documentation or definitive posts on the topic (especially from a current version of the app - I'm on 4.5.2).

    (Edits work?)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 10, 2011 @ 17:56
    Tom Fulton
    0

    Hi Jason,

    Check out this blog post, this is how I implemented on a recent site and it seems to work very well:  http://www.aaron-powell.com/umbraco-members-profiles

    I can then retrieve properties like so

                MemberProfile mp = ((MemberProfile)HttpContext.Current.Profile);
                FirstName.Text = mp.FirstName;
                LastName.Text = mp.LastName;

    And set them like so

                MemberProfile mp = ((MemberProfile)HttpContext.Current.Profile);
                mp.SetPropertyValue("mFirstName", FirstName.Text);
                mp.SetPropertyValue("mLastName", LastName.Text);

    Hope this helps,
    Tom

     

  • Jason P. Brown 8 posts 28 karma points
    Mar 10, 2011 @ 18:06
    Jason P. Brown
    0

    Thanks Tom, I appreciate your quick reply and will give it a look!

     

Please Sign in or register to post replies

Write your reply to:

Draft