Copied to clipboard

Flag this post as spam?

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


  • Arnold Visser 418 posts 778 karma points hq c-trib
    Oct 23, 2009 @ 11:32
    Arnold Visser
    0

    Member property not set, but member is created

    Intro

     

    • Umbraco: 4.0.2.1
    • .net 3.5
    • Windows 2008 IIS7

     

    Description

    Adding a member to the membergroup "customers" works.

    Exept, when I try to add member property values to the member (see code below, using getProperty), the property isn't filled?

    MemberControls.cs 


    public static bool CreateMember(string MemberName, string MemberPassword, string MemberEmail)

            {

                try

                {

                    MemberType mt = MemberType.GetByAlias("customer");

                    Member m = Member.MakeNew("MemberName", mt, new umbraco.BusinessLogic.User(0));


                    m.getProperty("ShopCustomerStreet").Value = "test";

                    m.XmlGenerate(new System.Xml.XmlDocument());

     

                    m.Save();


                    return true;

                }

                catch (Exception)

                {

                    return false;

                }

            }

    web.config

     

    add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="customer" passwordFormat="Hashed"

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Oct 23, 2009 @ 11:43
    Richard Soeteman
    0

    Hi Arnold,

    When you debug , set a breakpoint on catch (Exception) I'm pretty sure that somewhere an exeption is thrown.

    Hope it helps you,

    Richard

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Oct 23, 2009 @ 11:49
    Arnold Visser
    0

    @richard 

    Didn't include umbraco in my solution (only the dll) so I'll just set up a full umbraco solution then ;)

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Oct 23, 2009 @ 12:01
    Richard Soeteman
    0

    You don't have to. Only reference to umbraco, cms, businesslogic and Interaces dll's and it should work. 

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Oct 23, 2009 @ 12:09
    Arnold Visser
    0

    OMG! Umbraco already creates a user when using the asp:CreateUserWizzard! so that's why it didn't work! I tried to create the user AGAIN... 

    so this was enough:

    public static bool CreateMember(string MemberName, string MemberPassword, string MemberEmail)

            {

                    //Use a member type, it assumes a membertype with the alias "standard" is created

                    //In the member section

     

                    //select member just created

                    Member m = Member.GetMemberFromEmail(MemberEmail);

     

                    //set property

                    m.getProperty("ShopCustomerStreet").Value = MemberName;

     

                    //Generate member Xml Cache

                    m.XmlGenerate(new System.Xml.XmlDocument());

     

                    //Save member

                    m.Save();

     

                    return true;

     

            }

  • skiltz 501 posts 701 karma points
    Oct 23, 2009 @ 12:16
    skiltz
    0

    Umbraco uses the asp.net membership controls.  So any asp.net membership controls should do what they are intended to do.

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Oct 23, 2009 @ 12:23
    Arnold Visser
    0

    Next time i'll let the programmer do his job and I stick to mine ;)

  • vijay 129 posts 152 karma points
    Dec 22, 2009 @ 10:02
    vijay
    0

    To create a membership control see the below code hope it helps

    <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 9.35pt 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:379060294; mso-list-type:hybrid; mso-list-template-ids:-760287588 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-text:"%1\)"; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1 {mso-list-id:1408847456; mso-list-type:hybrid; mso-list-template-ids:-1242391786 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-text:"%1\)"; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2 {mso-list-id:1672949252; mso-list-type:hybrid; mso-list-template-ids:-1471658754 890779600 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l2:level1 {mso-level-number-format:roman-upper; mso-level-text:"%1\)"; mso-level-tab-stop:.75in; mso-level-number-position:left; margin-left:.75in; text-indent:-.5in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} -->

    Creating Member Type Control :

     

    While creating Member type Control programmatically first we have to create a website in .net

     

    Open solution explorer right click on it and Add folders and ADD bin and right click on bin

     

     click Add Reference and select Browse

     

    businesslogic.dll

    cms.dll

    umbraco.dll

    umbraco.DataLayer.dll

    umbraco.editorControls.dll

    controls.dll

    interfaces.dll

     

    Now right click on solution explore and click on Add New Item select Web User Control nad Name it as

     

    AddMembers.acsx click on ok.

     

    Now go to AddMembers.acsx.cs and add these Name spaces to play with Membertype programmatically.

     

    using umbraco.BusinessLogic;

    using umbraco.cms.businesslogic.member;

    using umbraco.presentation.nodeFactory;

    using umbraco.cms.businesslogic.datatype;

    using umbraco.cms.businesslogic;

     

    I)                   Our First target is to Create Membertype in Umbraco through Our .Net user control:-

     

    For that Take user control and Add textbox and Bitton Controls from tool box.

     

    Now on Button Create type click  we have to write the code below.

     

    The syntax for creating member type is

     

    Syntax :- Membertype.makenew(user u , string text)

     

    Where user is Admin or Editor etc provided / creted by umbraco.

     

    String Text is the name of the Member type you want to create.

     

    II)                Read All Member Types you Created:-

     

    Now our second target is to read all the member types we created.

     

    For that Go to .acsx and add Dropdownlist to Form.

     

    umbraco.cms.businesslogic.member;

     

    To read all the member types created the above name space provide one Function called

     

    MemberType.GetAll.

     

    We have to read all member types using an array like below and fill the dropdown according to that

     

    MemberType[] mt = MemberType.GetAll;

     

    III)             Delete Member Types:-

     

    To delete member types we have to create Member Type by Alias Name and Delete it.

     

    MemberType mt = MemberType.GetByAlias(DD_Membertypes.SelectedItem.Text);

           

    mt.delete();

     

    IV)                Create Tabs in Member Types:-

     

    To create tab in Member Type first we have to create member type by its alias and call

    AddVirtualTab() function.

     

    MemberType mt = MemberType.GetByAlias("" + DD_Membertypes.SelectedItem.Text + "");

    mt.AddVirtualTab(txt_TabText.Text);

     

    V)                Add Properties to Tab:-

     

    In this section total 3 parts are there

     

    1)      Read and Display Data types in umbraco

    2)      Read and Display Tabs Presented in umbraco

    3)      Create Property by given Name

     

    1)      Read and Display Data types in umbraco:-

     

    Now our target is to read all the Data types we created / Exist in Umbraco.

    For that Go to .acsx and add Dropdownlist to Form.

     

    using umbraco.cms.businesslogic.datatype;

     

    To read all the Data types created the above name space provide one Function called

     

    DataTypeDefinition.GetAll.

     

    We have to read all member types using an array like below and fill the dropdown according to that

    DataTypeDefinition[] dt_Def = DataTypeDefinition.GetAll();

     

    Note:-  We have to bind Dropdown with Data Type Name and Data Type ID Fields.

     

    2)      Read and Display Tab types in umbraco:-

     

    Now our target is to read all the Tab types we created in Umbraco.

     

    For that Go to .acsx and add Dropdownlist to Form.

     

    To read all tabs we created first we have to create Member Type and using the For loop we have to read the Tab Types we created.

     

    MemberType mt = MemberType.GetByAlias(DD_Membertypes.SelectedItem.Text.ToString());

          

    foreach(umbraco.cms.businesslogic.ContentType.TabI t in mt.getVirtualTabs)

     

    Note:- The Default tab Generic Properties we have to add manually to the data table.

     

    3)      Create Property Type by Given Name:-

     

    While creating Property first we have to create Member Type by its Alias

    And

    Create Data Type Definition by Data Type ID.

     

    Now Create Property using the syntax:

     

    1) Membertype.Addpropertytype (data type definition , string text , string alias text);

     

    And add Property to the tab

     

    2) property.TabId = selected tab’s TabID.

     

    And Save the Property

     

    3)Property.Save().

     

    Note:- To add Property to Generic Properties tab ignore steps 2) and 3).

Please Sign in or register to post replies

Write your reply to:

Draft