+1-888-365-2779
Try Now
More in this section

Forums / 3.x Pre-release forums (retired) / membership Customizing

membership Customizing

13 posts, 0 answered
  1. feras
    feras avatar
    8 posts
    Registered:
    16 Feb 2007
    11 Mar 2007
    Link to this post
    hi,
    i wanna know what are the possibilities of customizing the membership part,
    i mean in the users profile, i see only
    username
    email
    firstname
    lastname
    and roles
    what if i want to add pin number, country
    and make these info integrated in the control panel ?
    thx in advanced

  2. Slavo
    Slavo avatar
    13 posts
    Registered:
    21 May 2013
    12 Mar 2007
    Link to this post
    Hello Feras,

    There are three things you need to do in order to achieve what you want:
        1. Modify the Web.config file to include the new fields.
        2. Add the new fields to the controls for editing and creating users.
        3. Add the code to save and retrieve the new information to/from the database.

    1. Open the Web.config for your project and find this section:

    <profile defaultProvider="Sitefinity">
    ...
                <properties>
                    <add name="FirstName"/>
                    <add name="LastName"/>
                    <add name="TestProperty"/>
                </properties>
    </profile>


    Include a tag for the field that you want to create, as highlighted.

    2. Modify the control that edits the user information. This is <project directory>/Admin/CmsAdmin/User.aspx. Find the EditTemplate and InsertTemplate tags and modify the code in them as follows:

    <fieldset class="userinfo">                   
                        <ol>
                            <li><cc2:FieldLabel ID="lblFirstName" runat="server" Text="First name" TargetID="FirstName"></cc2:FieldLabel><asp:TextBox ID="FirstName" runat="server"></asp:TextBox></li>
                            <li><cc2:FieldLabel ID="lblLastName" runat="server" Text="Last name" TargetID="LastName"></cc2:FieldLabel><asp:TextBox ID="LastName" runat="server"></asp:TextBox></li>
                            <li><cc2:FieldLabel ID="lblTestProperty" runat="server" Text="Test Property" TargetID="TestProperty"></cc2:FieldLabel><asp:TextBox ID="TestProperty" runat="server"></asp:TextBox></li>
                        </ol>
    </fieldset>


    Make sure you change the markup in both templates. They show the newly created field when creating a new user and when editing an existing user. Now the new field will show up in the admin section of your project.

    3. However, in order for it to work, you have to add code to save its data in the database. To do this, open the code-behind file (User.aspx.cs) and add the following highlighted code:

    private void FillProfileData()
        {
            ...
                TextBox textBox = container.FindControl("FirstName") as TextBox;
                if (textBox != null)
                {
                    textBox.Text = profile.FirstName;
                }
                textBox = container.FindControl("LastName") as TextBox;
                if (textBox != null)
                {
                    textBox.Text = profile.LastName;
                }
                textBox = container.FindControl("TestProperty") as TextBox;
                if (textBox != null)
                {
                    textBox.Text = profile.TestProperty;
                }
            }
        }
    ...
    private void SaveUserProfile(string username)
        {
            ...
                TextBox textBox = container.FindControl("FirstName") as TextBox;
                if (textBox != null)
                {
                    profile.FirstName = textBox.Text;
                }
                textBox = container.FindControl("LastName") as TextBox;
                if (textBox != null)
                {
                    profile.LastName = textBox.Text;
                }
                textBox = container.FindControl("TestProperty") as TextBox;
                if (textBox != null)
                {
                    profile.TestProperty = textBox.Text;
                }
                profile.Save();
            }
        }


    With this final step, you should have a new field for every user in your project. Of course, you can name it the way you like.You only need to change "TestProperty" in the above example with your own name.

    Regards,
    Slavo
    the telerik team
  3. feras
    feras avatar
    8 posts
    Registered:
    16 Feb 2007
    12 Mar 2007
    Link to this post
    wow,
    could not be easier , and really thx alot for the great detailed explaination.
    and this i exactly what i want, but when i open the User.aspx
    file in visual studio i cannot edit it, it is grayed out in addition to error message "Error creating control"
    ?



  4. Slavo
    Slavo avatar
    13 posts
    Registered:
    21 May 2013
    13 Mar 2007
    Link to this post
    Hello feras,

    I guess that you are trying to edit the User.aspx file in design mode. The error occurs because in the master page, instead of a normal <form> tag, we use our <CmsForm> tag. If you change it to a normal form tag, you will be able to view the page in design mode. Later, when you are done, you can replace the <form> tag with <CmsForm>.
    However, we advise you to make the changes in source mode and everything will be fine.
    The master page for Users.aspx is ~/Admin/Administration.master. I've included the markup in point 2 from the previous post so you shouldn't have any problems. Just make sure that you make the changes in both EditTemplate and InsertTemplate.

    Best wishes,
    Slavo
    the telerik team
  5. feras
    feras avatar
    8 posts
    Registered:
    16 Feb 2007
    13 Mar 2007
    Link to this post
    hi,
    thx fore reply, that is ok but why is that ? i mean the method you chose ?
    i feel much better working in design view , it is much more easier,
    but again thx alot for the code and time

  6. Slavo
    Slavo avatar
    13 posts
    Registered:
    21 May 2013
    15 Mar 2007
    Link to this post
    Hello Feras,

    In the general case, it's up to you to work in design or source mode - it's all the same. If you prefer to use the designer instead of writing code, that's fine. However, if you want the controls to be modifiable in design mode, you have to implement the logic when creating the controls. Indeed, for some of our controls this has not been done yet. That is why I think that it would be easier to work in source mode. We will defienitely do our best to provide better design time support for the official release.

    Sorry for any inconvenience that this may be causing you.

    All the best,
    Slavo
    the telerik team
  7. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    19 Aug 2010
    Link to this post
     
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Aug 2010
    Link to this post
    Hi Kieran,

    You do not have to extend the code behind. You need to put your controls in the Users.aspx inside ManageProfile control. This control will automatically persists the values. Note that the control has two modes - Edit and Insert, so your custom profile properties should be added for both the modes. The controls that you will use in the template should implement one of the following interfaces
    • ICheckBoxControl
    • ITextControl
    You can use DropDownList and HiddenField as well.
    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Dan
    Dan avatar
    24 posts
    Registered:
    02 Oct 2012
    17 Jan 2011
    Link to this post
    This doesn't seem to work for adding non-custom fields to the form (e.g. - IsLockedOut, IsApproved, etc.)  Is there a way to extend the form to include controls that allow you edit those fields?  I found this helpful post about extending the List view for this purpose - http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/locked-out-users-accounts.aspx - but have not been able to figure out how to customize the Edit / Insert templates to include the same fields.  Is this possible?

    Thanks, DanO
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jan 2011
    Link to this post
    Hi ,

    Inside ~/Sitefinity/Admin/CmsAdmin/Users.aspx there is a ManageUsers control  which wraps ManageProfile control. The ManageProfile control has Insert and Edit mode which you can extend with other controls.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Dan
    Dan avatar
    24 posts
    Registered:
    02 Oct 2012
    17 Jan 2011
    Link to this post

    Yep - I understood that from the earlier posts, and was able to get it working fine with custom fields, no problem.  However, if I add a field for IsLockedOut (an existing field) it doesn't persist the value.

    So for instance, I added a Company Name (custom) field, and it persists automatically (without any code behind updates):

    <li>
        <cc2:FieldLabel ID="lblCompanyName" runat="server" Text="Company Name" TargetID="CompanyName">
        </cc2:FieldLabel>
        <asp:TextBox ID="CompanyName" runat="server"></asp:TextBox>
    </li>

    But when I tried to add a control for the IsLockedOut property, it doesn't persist:

    <li
           <cc2:FieldLabel ID="lblIsLocked" runat="server" Text="User is Locked" TargetID="IsLockedOut"></cc2:FieldLabel
           <asp:CheckBox ID="IsLockedOut" runat="server"></asp:CheckBox
    </li>

    Is there a way to do this?  As I mentioned in my last post, I found a post that describes how to achieve this via the GridView, but am looking to do it in ManageProfile.

    Thanks, DanO
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jan 2011
    Link to this post
    Hello,

    You could subscribe for the Save button click event and persist the logic in the click event directly in the template. You could access the control of ManageUsers class OnPreRender. You could find the controls you need from Telerik.Security.WebControls.ManageUsers.EditContainer or Telerik.Security.WebControls.ManageUsers.ListContainer. You could also subscribe for manageUsers.UpdatingUser, manageUsers.CreatingUser, manageUsers.DeletingUser events.

    Check this post for further reference.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Dan
    Dan avatar
    24 posts
    Registered:
    02 Oct 2012
    17 Jan 2011
    Link to this post
    Thanks for the info!  I'll give that a shot.

    -DanO
Register for webinar
13 posts, 0 answered