Copied to clipboard

Flag this post as spam?

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


  • Giacomo Cosenza 16 posts 36 karma points
    Apr 13, 2011 @ 16:41
    Giacomo Cosenza
    0

    Create User Form Registration

    Hi,
    I'm implementing a form to register a user on the portal umbraco.
    I created a UserControl using Visual Studio 2008. I used the CreateUserWizard toasp. net and wrote this piece of code.

     

    code-behind: c#

     protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
     {
                /* User is created and setting extra parameters to profile */
                TextBox UserNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
                string username = UserNameTextBox.Text;
                MembershipUser User = Membership.GetUser(username);
                umbraco.cms.businesslogic.member.Member member = new umbraco.cms.businesslogic.member.Member((int)User.ProviderUserKey);
                /* Here you can access properties for the member */
                umbraco.cms.businesslogic.property.Property FullNameProperty = member.getProperty("fullname"); // Property alias
                TextBox FullNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FullName");
                FullNameProperty.Value = FullNameTextBox.Text;
                Roles.AddUserToRole(CreateUserWizard1.UserName, "NuneatonMember");
            }

     

    user Control:

    <asp:CreateUserWizard ID="CreateUserWizard1" OnContinueButtonClick="CreateUserWizard1_ContinueButtonClick" OnCreatedUser="CreateUserWizard1_CreatedUser" runat="server">
         <WizardSteps>
             <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
       <ContentTemplate>
        First Name :<asp:TextBox Runat="server" ID="FullName" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="FullNameVal" runat="server" ControlToValidate="FullName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <br/>
        Last Name :<asp:TextBox Runat="server" ID="LastName" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="LastNameVal" runat="server" ControlToValidate="LastName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <br/>
        Username :<asp:TextBox Runat="server" ID="UserName" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="UserNameVal" runat="server" ControlToValidate="UserName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <br/>
        E-mail :<asp:TextBox Runat="server" ID="Email" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="EmailVal" runat="server" ControlToValidate="Email" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator id="valRegEx" runat="server" ControlToValidate="Email" ValidationExpression=".*@.*\..*" ErrorMessage="* is not a valid e-mail address." ValidationGroup="CreateUserWizard1" display="dynamic"></asp:RegularExpressionValidator>
        <br/>
        Password :<asp:TextBox Runat="server" ID="Password" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="PasswordVal" runat="server" ControlToValidate="Password" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <br/>
        Confirm Password :<asp:TextBox Runat="server" ID="ConfirmPassword" CssClass="user_info"></asp:TextBox>
        <asp:RequiredFieldValidator ID="PConfirmVal" runat="server" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
        <br/>
        <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ValidationGroup="CreateUserWizard1" ErrorMessage="Foul: Password and Confirmation Password do not match. Fix them."></asp:CompareValidator>
        <asp:literal runat="server" enableviewstate="true" id="FailureText"></asp:literal>
       </ContentTemplate>
      </asp:CreateUserWizardStep>
             <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"></asp:CompleteWizardStep>
         </WizardSteps>
    </asp:CreateUserWizard> 

     


    I want to know where I find the dll directive to use 

    umbraco.cms.businesslogic.member.Member

    In addition, the data entered in the form as they are managed? What is the table onwhich are stored? I have to set the parameters passed into umbraco web.config?

    Many thanks
    Regards.

    G.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 13, 2011 @ 19:19
    Jan Skovgaard
    0

    Hi Giacomo

    You need to reference cms.dll, umbraco.dll and businesslogic.dll, which you will find in the bin folder of Umbraco.

    I'm not sure what you mean by your last question? Could you ellaborate a bit more?

    /Jan

  • Giacomo Cosenza 16 posts 36 karma points
    Apr 13, 2011 @ 19:59
    Giacomo Cosenza
    0

    Thanks for the reply,Jan.

    I mean, after you import the UserControl in umbraco and have it appear correctly in the template, how do I manage the connection to the database and how to write the user's entry in the database? I need to change the web.config? Have you ever done something like that? I explained?

     

    Thanks.

    G.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 13, 2011 @ 22:06
    Jan Skovgaard
    0

    Hi G

    Well, I'm not sure why you want to connect to the database since you seem to be creating a member in the member section of Umbraco with the above code. Umbraco is based on the standard ASP.NET membership provider so I guess the above code should take care of creating the members in the member section or am I mistaken? :-)

    /Jan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 22:17
    Dirk De Grave
    0

    as you've not changed anything to web.config, you'll be using the standard umbraco membership provider (which is an implementation of the asp.net membership provider), meaning your members will be stored in umbraco's database, more specifically in two different tables. Part of the member data is stored in cmsMember table whereas most of the 'custom' properties are stored in the cmsPropertyData table.

    Don't need to manage a connection to the db if using the umbraco membership provider, it's taken care of for you (umbraco membership provider uses the value specified in web.config's umbracoDbDSN appsettings)

    Of course, you still have the option of changing some of the properties for the membership provider, and umbraco even has a few more... All settings can be found in the web.config.

    Here's a nice overview of the different settings: http://our.umbraco.org/wiki/how-tos/membership-providers/umbracomembershipprovider-properties

     

    Cheers,

    /Dirk

     

     

     

  • Giacomo Cosenza 16 posts 36 karma points
    Apr 14, 2011 @ 11:16
    Giacomo Cosenza
    0
    No member with loginname: giacomo.cosenza Exists
    0,0217720408599417
    0,000636
    
    
    No member with loginname:  Exists
    0,0229680029165718
    0,001196
    
    Unhandled Execution Error
    Object reference not set to an instance of an object.
    at umbraco.cms.businesslogic.Content.CreateContent(ContentType ct)
    at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String LoginName, String Email, MemberType mbt, User u)
    at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String Email, MemberType mbt, User u)
    at umbraco.providers.members.UmbracoMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)
    at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser()
    at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e)
    at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)
    at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    I riceved this error after I insert the user data. Why?

    I imported the *.dll files and i compiled the source correctly. But after I imported the user control I give this error.

    Any Ideas?

    Thanks

     

    G. 

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Apr 14, 2011 @ 11:32
    Michael Latouche
    0

    Hi Giacomo,

    I think this error occurs because you need to define a MemberType in your Umbraco back-end, and refer it in your UmbracoMembershipProvider definition in the web.config.

    You can find more info about this at this wiki, page : http://our.umbraco.org/wiki/how-tos/membership-providers/umbracomembershipprovider-properties

    Basically, your web.config definition will look something like this:

    <add name="UmbracoMembershipProvider" 
     
    type="umbraco.providers.members.UmbracoMembershipProvider"
     
    enablePasswordRetrieval="true"
     
    enablePasswordReset="false"
     
    requiresQuestionAndAnswer="true"
     
    defaultMemberTypeAlias="MyDefaultMemberTypeAlias"
     
    passwordFormat="Hashed"
     
    umbracoApprovePropertyTypeAlias="approved"
     
    umbracoLockPropertyTypeAlias="lock"
     
    umbracoFailedPasswordAttemptsPropertyTypeAlias="failed_logins"
     
    umbracoCommentPropertyTypeAlias="comments"
     
    umbracoLastLoginPropertyTypeAlias="last_login"
     
    umbracoPasswordRetrievalQuestionPropertyTypeAlias="question"
     
    umbracoPasswordRetrievalAnswerPropertyTypeAlias="answer" />

    My guess is that your are either missing the "defaultMemberTypeAlias" attribute in the membership provider definition, or you have not actually created the MemberType "MyDefaultMemberTypeAlias" in the Membership section of the Umbraco backend.

    Hope this helps.

    Cheers,

    Michael.

  • Giacomo Cosenza 16 posts 36 karma points
    Apr 14, 2011 @ 13:43
    Giacomo Cosenza
    0

    Nothing. But the C# code above is correct? Or should I change anything?

    My web.config is:

     <add name="UmbracoMembershipProvider"
               type="umbraco.providers.members.UmbracoMembershipProvider"
               enablePasswordRetrieval="true"
               enablePasswordReset="false"
               requiresQuestionAndAnswer="false"
               defaultMemberTypeAlias="_umbracoSystemDefaultProtectType"
               umbracoApprovePropertyTypeAlias="approved"
               umbracoLockPropertyTypeAlias="lock"
               umbracoFailedPasswordAttemptsPropertyTypeAlias="failed_logins"
               umbracoCommentPropertyTypeAlias="comments"
               umbracoLastLoginPropertyTypeAlias="last_login"
               umbracoPasswordRetrievalQuestionPropertyTypeAlias="question"
               umbracoPasswordRetrievalAnswerPropertyTypeAlias="answer" />

     

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Apr 14, 2011 @ 15:28
    Michael Latouche
    0

    Hi Giacomo,

    Your C# code looks ok at first look, but since the error occurs in the CreateNew method, I don't think that the code gets to your event handler: it crashes before that, at the moment of creating the member.

    From your previous post, I am not sure if you have checked whether you had a MemberType with alias "_umbracoSystemDefaultProtectType" in your backend. Is it the case? And if it is, do you have a property defined in that MemberType for each the "umbraco...TypeAlias" you mention in your web.config?

    Cheers,

    Michael.

  • Giacomo Cosenza 16 posts 36 karma points
    Apr 14, 2011 @ 16:09
    Giacomo Cosenza
    0

    Hi guys,

    The user that I insert in the form is added to the member of umbraco :)

    But

     

    • After I click "create user" raises an exception :

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    • I commented the default part of web.config and I insert the piece of web.config above. In this way I can not logged into umbraco with the credentials
    For logged I intended the login in the portal by the control :
    <asp:LoginView ID="UmbracoLoginView" runat="server">
                  <AnonymousTemplate>
                    <asp:Login ID="Login2" runat="server" DestinationPageUrl="/contact-us/memberarea.aspx"></asp:Login>
                  </AnonymousTemplate>
                  <LoggedInTemplate>
                    Wellcome,
                    <asp:LoginName ID="LoginName1" runat="server" />
                    <asp:LoginStatus ID="LoginStatus1" runat="server" />
                  </LoggedInTemplate>
    </asp:LoginView>
    Why?
    Thanks,
    Regards.
    G.

     

  • Giacomo Cosenza 16 posts 36 karma points
    Apr 14, 2011 @ 18:56
    Giacomo Cosenza
    0

    Now, if I comment this part of web.config

     <add 
                name="UmbracoMembershipProvider" 
                type="umbraco.providers.members.UmbracoMembershipProvider" 
                enablePasswordRetrieval="false" 
                enablePasswordReset="false" 
                requiresQuestionAndAnswer="false" 
                defaultMemberTypeAlias="Another Type" 
                passwordFormat="Hashed" />

    and leave this part:

     <add 
               name="UmbracoMembershipProvider"
               type="umbraco.providers.members.UmbracoMembershipProvider"
               enablePasswordRetrieval="false"
               enablePasswordReset="false"
               requiresQuestionAndAnswer="false"
               defaultMemberTypeAlias="memberRegister"
               umbracoApprovePropertyTypeAlias="approved"
               umbracoLockPropertyTypeAlias="lock"
               umbracoFailedPasswordAttemptsPropertyTypeAlias="failed_logins"
               umbracoCommentPropertyTypeAlias="comments"
               umbracoLastLoginPropertyTypeAlias="last_login"
               umbracoPasswordRetrievalQuestionPropertyTypeAlias="question"
               umbracoPasswordRetrievalAnswerPropertyTypeAlias="answer" />

    I can create an user, but I can't login in.

    Viceversa, i can login with creadentials of users that I added, but i can't register others users.

    Why?

    Any Ideas? 

    Thanks.

    G.

     

  • adarsh 46 posts 66 karma points
    Jun 22, 2011 @ 18:04
    adarsh
    0

    Hi Giacomo Cosenza,

    Did you get this working..

    iam working on the registration form my website.. iam not getiing the proper solution some bits works fine..

    can you please provide the information will be great.

     

  • Giacomo Cosenza 16 posts 36 karma points
    Jun 22, 2011 @ 18:39
    Giacomo Cosenza
    0

    Hi adarsh,

    what is the problem? What do you done so far? 

    Give me some information about your work.

    thanks.

    Giacomo

  • adarsh 46 posts 66 karma points
    Jun 22, 2011 @ 19:38
    adarsh
    0

    i just used micsoft createwizard stuff its work but if i modify the things its doesn't work

    like i added contentemplate and few more stuff it will not add in member fields its just add the username and password and

    email id and rest of the fields blank.

    and i just did wht you done in code of the example wht you specified in the previous post.

     

  • Dupeng 5 posts 25 karma points
    Jul 01, 2013 @ 05:56
    Dupeng
    0

    thanks,Jan Skovgaard !

Please Sign in or register to post replies

Write your reply to:

Draft