Copied to clipboard

Flag this post as spam?

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


  • Berdia 45 posts 67 karma points
    Feb 19, 2011 @ 22:19
    Berdia
    0

    Add custom fields to create user control in Umbraco

    Hi,

    I am using CreateUserWizard control in Umbraco to enable users to register on website. Is it possible to add custom fields (city, country, zip code etc) so they can be registered to the database table and then retrieved and see under Membership in Umbraco?

    Is it possible to do it using Umbraco membership provider or shall I use ASP.NET membership provider and use custom control?

    Following is a code I have at the moment. I need to know how to enhance it to add custom fields.

    <%@ Master Language="C#" Debug="true" MasterPageFile="~/masterpages/C_Master.master" AutoEventWireup="true" %>
    <script runat="server">

    protected void newUserWizard_CreatedUser(object sender, EventArgs e)
    {
        Roles.AddUserToRole(newUserWizard.UserName, "standard");
    }

    </script>


    <asp:content ContentPlaceHolderId="main" runat="server">
     <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
    <asp:CreateUserWizard ID="newUserWizard" ContinueDestinationPageUrl="/default.aspx" OnCreatedUser="newUserWizard_CreatedUser" runat="server">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="createUserWizardStep" runat="server"></asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="completeWizardStep" runat="server"></asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>

     

    </asp:content>

     

    Thank you

  • Daniel Bardi 927 posts 2562 karma points
    Feb 20, 2011 @ 06:53
    Daniel Bardi
    0

    You should be able to use the umbraco membership provider.

    Create the fields in the member section and then add properties to the membership section in the web.config.

    Look at my Profile Editor Macro package for some direction ( http://our.umbraco.org/projects/website-utilities/profile-editor-macro )...

    I honestly haven't done it before, but I am sure it can be done.

     

  • Berdia 45 posts 67 karma points
    Feb 20, 2011 @ 14:31
    Berdia
    0

    Daniel,

    Thank you for quick reply. I did as you said:

    I have added extra fields into web.config, also created fields in the member section and selected "Show on Profile"

    Following is my HTML for CreateUserWizardControl. As you can see I added First Name, Last Name and Company Name as extra fields.

    <%@ Master Language="C#" Debug="true" MasterPageFile="~/masterpages/C_Master.master" AutoEventWireup="true" %>
    <script runat="server">

    protected void newUserWizard_CreatedUser(object sender, EventArgs e)
    {
        Roles.AddUserToRole(newUserWizard.UserName, "standard");
    }

    </script>


    <asp:content ContentPlaceHolderId="main" runat="server">
     <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
    <asp:CreateUserWizard ID="newUserWizard" ContinueDestinationPageUrl="/default.aspx" OnCreatedUser="newUserWizard_CreatedUser" runat="server">
        <WizardSteps>
    <asp:WizardStep ID="CreateUserWizardStep0" runat="server">
           
             <table class="tableText" style="background-color: #FFFFFF" align="center">
            <tr>
            <th class="style7" style="font-size: medium">Personal information:</th>
            </tr>
            <tr align="right" style="font-family: vani; color: #FF0000"><th>* Required Fields</th></tr>
                        <tr>
                    <td class="style8">
                        First Name:*</td>
                    <td class="style9">
                        <asp:TextBox ID="FirstName" runat="server" Width="200px"></asp:TextBox>
                    </td>
                    <td class="style5">
                        </td>
                </tr>
            <tr>
            <td class="style8">Last Name:*</td>
            <td class="style9"><asp:TextBox runat="server" ID="LastName" Width="200px" /></td>
                <td class="style5">
                               </td>
            </tr>
            <tr>
            <td class="style7">Company Name:</td>
            <td class="style9">
                <asp:TextBox ID="CompanyName" runat="server" Width="200px"></asp:TextBox>
                </td>
                <td class="style5">
                    &nbsp;</td>
            </tr>
                        </table>
         
            </asp:WizardStep>
            <asp:CreateUserWizardStep ID="createUserWizardStep" runat="server"></asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="completeWizardStep" runat="server"></asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>

     

    </asp:content>

     I did a new registration but it only creates User Name, Email and Password (default fields of CreateUserWizard) none of the extra fields have been registered into the Umbraco membership.

    Is it possible to enter extra field values into SQL database membership table?

    Thank you.

  • Daniel Bardi 927 posts 2562 karma points
    Feb 20, 2011 @ 18:26
    Daniel Bardi
    0

    Here's an old article (but still relevant) that might help you.

    http://odetocode.com/Articles/440.aspx

Please Sign in or register to post replies

Write your reply to:

Draft