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 @ 23:10
    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 (ListBox).

    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");

    TextBox phone= (TextBox)CreateUserWizardStep0.FindControl("Phone");
    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

  • Dan 1288 posts 3921 karma points c-trib
    Jan 09, 2011 @ 00:35
    Dan
    1

    Hi ds,

    A quick thing to try would be:

    profile["workType"] = WorkType.SelectedItem.Value;

    Any joy?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 09, 2011 @ 11:30
    Dirk De Grave
    0

    Yup, I think Dan's right, may have to store the value rather than the text of the selected item from the dropdown. Should also check how values are stored when working with a 'Dropdown multiple' (it might be comma separated...)

    Cheers,

    /Dirk

  • ds 191 posts 223 karma points
    Jan 09, 2011 @ 12:18
    ds
    0

    Hi Dan, Dirk

     

    I tried what you suggested but I am getting still the same result. Also where can I find the information how values are stored when working with 'dropdown multiple' Dirk?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 09, 2011 @ 13:52
    Dirk De Grave
    0

    Depends on the "dropdown" variant, and sometimes the data stored in the db is different then data stored in the published xml. So, best place to start looking at is the cmsPropertyData table which holds the value of the property on your document when editing/saving it, and have a look at the umbraco.config file in the /App_Data folder (or /data folder - depends on web.config settings) and check how the value is stored in there.

     

    Hope this helps.

    Regards,

    /Dirk

  • ds 191 posts 223 karma points
    Jan 10, 2011 @ 10:21
    ds
    0

    I checked cmsPropertyData and confirmed that 'work type" has been successfully saved into database. The Problem is on members section of admin backend, work type property is not displayed at all.

  • ds 191 posts 223 karma points
    Jan 11, 2011 @ 13:18
    ds
    0

    Dirk, Do you have any idea what might cause the empty list?

    I also added a property to a member type and that property uses data type with prevalues. I can successfully see the values on frontend but the problem is that after selecting a value or values from the list and creating user, selected values on admin backend are not selected.

    Hope to give me some feedback,

    thanx

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 11, 2011 @ 13:36
    Dirk De Grave
    0

    would have to look into this, currently don't have a clue why it's not displaying in the backend

     

    cheers,

    /Dirk

  • ds 191 posts 223 karma points
    Jan 12, 2011 @ 15:52
    ds
    0

    Dirk,

    That code snippet in the following works as expected except profile["worktype"] line.

                                <asp:ListBox ID="WorkType" runat="server" SelectionMode="Multiple">
    <asp:ListItem Value="Ahap Malzeme" >Ahap Malzeme</asp:ListItem>
    <asp:ListItem Value="Akaryakt Bayileri">Akaryakt Bayileri</asp:ListItem>
    <asp:ListItem Value="Akvaryum-Hayvan Bakm ve Malzemeleri">Akvaryum-Hayvan Bakm ve Malzemeleri</asp:ListItem>
    <asp:ListItem Value="Alveri Merkezleri">Alveri Merkezleri</asp:ListItem>
    <asp:ListItem value="Ambalaj">Ambalaj</asp:ListItem>
    </asp:ListBox>
            protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
    TextBox UserName = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName");

    TextBox Address = (TextBox)CreateUserWizardStep0.FindControl("Address");
    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["address"] = Address.Text;
    profile["sector"] = Sector.SelectedItem.Value;
    profile["workType"] = WorkType.SelectedItem.Value;
    profile.Save();
    }

    I created a dropdown list multiple data type as nvarchar for worktype and that work type has prevalues as same as listbox. How can I save user selection from listbox into worktype property so I can see it on admin section of member selected?

    Thanx

Please Sign in or register to post replies

Write your reply to:

Draft