Copied to clipboard

Flag this post as spam?

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


  • pat 124 posts 346 karma points
    Mar 29, 2011 @ 17:59
    pat
    0

    additional fields in membership and sign up page

    I am a asp.net developer but pretty new to umbraco , In members we can create new members, but how I include this as form for sign up, and how to add additional fields such as comoany name telephone contact name address so on.. please guide from scratch.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 29, 2011 @ 22:24
    Jan Skovgaard
    0

    Hi Pat and welcome to the wonderfull world of Umbraco.

    Since Umbraco is based on the standard ASP.NET membership provider it's pretty easy to create signup form. I think you can benefit from reading more about the "CreateUserWizard" control here: http://msdn.microsoft.com/en-us/library/ms178329.aspx#the_createuserwizard_control.

    The additional fields on the member you need create as properties on your member type in Umbraco and then it should be possible for you to create a user control based on the above adding some additional fields in the form where you can use the API to fetch those values and populate them into the correct fields on the newly created member.

    You can read more about the membershop API in here:http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-members

    And generally you can read more API examples overall in here:http://our.umbraco.org/wiki/reference/api-cheatsheet

    I hope the above pointers are enought to get you started? :-)

    /Jan

     

  • pat 124 posts 346 karma points
    Mar 30, 2011 @ 17:04
    pat
    0

    In my code  User underline in read, I have add reference to umbraco.dll and cms.dll from website  bin folder did I missed something?

     

     

    Member m = Member.MakeNew(tusername.Text, dt, new umbraco.BusinessLogic.User(0));

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

    Hi Pat

    Do you get any errors in visual studio? If so...what does it say?

    /Jan

  • pat 124 posts 346 karma points
    Mar 31, 2011 @ 11:24
    pat
    0

    sort problem when add businesslogic.dll. to check user exist or not i have used Member.IsMember(String username) and to check user exist with given email I am going to use System.Web.Security.Membership.GetUserNameByEmail(String Email)

    hope this should work?

  • pat 124 posts 346 karma points
    Mar 31, 2011 @ 11:42
    pat
    0
    Error creating control (usercontrols/mySignUPUserControl.ascx).
    Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!

    I got this error after added it in page ?  this is my code

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco.cms.businesslogic.member ;


    namespace umbracoUsercontrols
    {
        public partial class mySignUPUserControl : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }

            protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
            {

                TextBox ttitle = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txttitle");
                TextBox tfirstName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfirstname");
                TextBox tlastName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtlastname");
                TextBox tfullName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfullname");
                TextBox taddressline1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtAddressline1");
                TextBox taddressline2 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtAddressline2");
                TextBox tcity = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtcity");
                TextBox tcounty = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtcounty");
                TextBox tpostcode = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtpotcode");
                TextBox tphone = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtTelephone");
                TextBox tfax = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfax");
                TextBox temail = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtemail");
                TextBox tcompany = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtcompany");
                TextBox tpassword = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtpassword");
                TextBox tusername = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtusername");
                TextBox tcountry = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtcountry");
                CheckBox subscribeCheckBox = (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
                if (UserExists(tusername.Text)   &&  UserExistsforEmail (temail .Text ) )
                {
                    Literal err = (Literal)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ErrorMessage");
                    err.Text  = "User name or Email already registered";
                }
                else

                {
               
                MemberType dt = MemberType.GetByAlias("Standard");
               // MemberGroup mg = MemberGroup.GetByName("Member Group");

                Member m = Member.MakeNew(tfullName.Text, dt, new umbraco.BusinessLogic.User(0));
                m.Password = tpassword.Text;
                m.Email = temail.Text;
                m.LoginName = tusername.Text;
               
                //m.AddGroup(mg.Id);
                m.getProperty("firstName").Value = tfirstName.Text;
                m.getProperty("lastName").Value = tlastName.Text;
                m.getProperty("phone").Value = tphone.Text;
                m.getProperty("title").Value = ttitle.Text;
                m.getProperty("company").Value = tcompany.Text;
                m.getProperty("addressLine1").Value = taddressline1.Text;
                m.getProperty("addressLine2").Value = taddressline2.Text;
                m.getProperty("city").Value = tcity.Text;
                m.getProperty("county").Value = tcounty.Text;
                m.getProperty("postCode").Value = tpostcode.Text;
                m.getProperty("fax").Value = tfax.Text;
                m.getProperty("fullName").Value = tfullName.Text;
                m.getProperty("country").Value = tcountry.Text;
                if (subscribeCheckBox.Checked == true)
                {
                    m.getProperty("subscribeNewsLetter").Value = true;

                }
                else
                {
                    m.getProperty("subscribeNewsLetter").Value = false;
                }
                m.XmlGenerate(new System.Xml.XmlDocument());
                    m.Save();
                }
            }

            private bool UserExists(string username)
            {
                if (Member.IsMember(username) == true) { return true; }

                return false;
            }

            private bool UserExistsforEmail(string emailadd)
            {
                String m = System.Web.Security.Membership.GetUserNameByEmail(emailadd);
                if (String.IsNullOrEmpty (m) ){ return false; }
                return true;
            }
       
        }
    }

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 31, 2011 @ 20:56
    Jan Skovgaard
    0

    Hi Pat

    When you have made your build are you then sure you have remembered to copy both the generated .dll and user control over in the proper folders in your installation?

    /Jan

  • pat 124 posts 346 karma points
    Apr 01, 2011 @ 18:16
    pat
    0

    yes both loaded, now I can see the sign up page and when I try create new member it gives error No member with loginname: ABCD1234

    I have change my code

            private bool UserExists(string username)

            {

                if (System.Web.Security.Membership.GetUser (username) != null) { return true; }

     

                return false;

            }

     

            private bool UserExistsforEmail(string emailadd)

            {

                String m = System.Web.Security.Membership.GetUserNameByEmail(emailadd);

                if (String.IsNullOrEmpty (m) ){ return false; }

                return true;

            }

     

         

     

Please Sign in or register to post replies

Write your reply to:

Draft