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

Forums / Security / User registration: Email as user name

User registration: Email as user name

15 posts, 1 answered
  1. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    29 Jun 2010
    Link to this post
    I want to make the users have their email as user name. I don´t want the user name textbox to be visible in the create user wizard, but when a user saves their profile I want to make their email name to be put in their user name field as well as inn their email field.

    I think I have read something similar before on the forums but I can´t find the post now. Is the anyone who can help me with this?

    Note! The public page seems to work but not the admin page. In the admin page I get the error message.

    /Johnny
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Jun 2010
    Link to this post
    Hi Johnny,

    You can take  a look at CreateWizardUser explains

    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
    Answered
  3. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    29 Jun 2010
    Link to this post
    That seems to be exactly what I need.

    Thanks Ivan!
  4. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    29 Jun 2010
    Link to this post
    Spoke to soon. My Edit profile page has stopped working after the changes and I can´t seem to see what´s going wrong...

    [NullReferenceException: Objektreferensen har inte angetts till en instans av ett objekt.]
       Sitefinity_UserControls_Login_ManageProfileControl.OnPreRender(EventArgs e) +497
       System.Web.UI.Control.PreRenderRecursiveInternal() +80
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ManageProfileControl.ascx.cs" Inherits="Sitefinity_UserControls_Login_ManageProfileControl" %>
    <%@ Register Assembly="Telerik.Security" Namespace="Telerik.Security.WebControls" TagPrefix="cc1" %>
      
    <cc1:ManageProfile ID="manageProfile" runat="server" Mode="Edit" UsernameIfNoNames="false">
        <EditTemplate>
            <fieldset>
                    <ul>
                        <li>
                            <asp:Label AssociatedControlID="FirstName" ID="FirstNameLabel" runat="server" Text="Förnamn:" />
                            <asp:TextBox ID="FirstName" runat="server" />
                            <asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="FirstName" 
                                ErrorMessage="Var god ange ditt förnamn">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="LastName" ID="LastNameLabel" runat="server" Text="Efternamn:" />
                            <asp:TextBox ID="LastName" runat="server" />
                            <asp:RequiredFieldValidator ID="LastNameRequired" runat="server" ControlToValidate="LastName" 
                                ErrorMessage="Var god ange ditt efternamn">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="City" ID="CityLabel" runat="server" Text="Stad:" />
                            <asp:TextBox ID="City" runat="server" />
                            <asp:RequiredFieldValidator ID="CityRequired" runat="server" ControlToValidate="City" 
                                ErrorMessage="Var god ange din stad">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="Street" ID="StreetLabel" runat="server" Text="Gata:" />
                            <asp:TextBox ID="Street" runat="server" />
                            <asp:RequiredFieldValidator ID="StreetRequired" runat="server" ControlToValidate="Street" 
                                ErrorMessage="Var god ange din gata">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="Zip" ID="ZipLabel" runat="server" Text="Postnummer:" />
                            <asp:TextBox ID="Zip" runat="server" />
                            <asp:RequiredFieldValidator ID="ZipRequired" runat="server" ControlToValidate="Zip" 
                                ErrorMessage="Var god ange ditt postnummer">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="Telephone" ID="TelephoneLabel" runat="server" Text="Tele:" />
                            <asp:TextBox ID="Telephone" runat="server" />
                            <asp:RequiredFieldValidator ID="TelephoneRequired" runat="server" ControlToValidate="Telephone" 
                                ErrorMessage="Var god ange ditt telefonnummer">*</asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:Label AssociatedControlID="GolfClub" ID="GolfClubLabel" runat="server" Text="Golfklubb:" />
                            <asp:DropDownList ID="GolfClub" runat="server">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="GolfClubRequired" runat="server" ControlToValidate="GolfClub"
                                ErrorMessage="Var god ange en golfklubb" ToolTip="Välj din golfklubb">*</asp:RequiredFieldValidator>
                        </li>
                    </ul>
                </fieldset>
        </EditTemplate>
    </cc1:ManageProfile>
    <asp:LinkButton ID="cmdSaveUser" Text="Spara" CommandName="Save" OnCommand="cmdSaveUser_Command" runat="server"></asp:LinkButton>
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security;
    using Telerik.Security;
    using Telerik.Cms;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Web;
      
    public partial class Sitefinity_UserControls_Login_ManageProfileControl : System.Web.UI.UserControl
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
      
            var list = (DropDownList)FindControlRecursive(manageProfile, "GolfClub");
            if (list != null)
            {
                // populate the combo with some data
                // create a new instance of CmsManager
                Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
                // get the current node of sitemap
                Telerik.Cms.Web.CmsSiteMapNode golfClubs = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode("~/Golfklubbar.aspx");
                // get the CmsPage represented by the current node and extract its ID
                Telerik.Cms.ICmsPage currentPage = golfClubs.CmsPage;
                Guid currentPageId = currentPage.ID;
                // get all child pages of currentPage
                IList childPages = cmsManager.GetPages(currentPageId);
      
                foreach (Telerik.Cms.ICmsPage page in childPages)
                {
                    list.Items.Add(new ListItem(page.MenuName, page.ID.ToString()));
                    //GolfClub.Items.Add(new RadComboBoxItem(page.MenuName, page.ID.ToString()));
                }
      
                ProfileCommon profile = Profile.GetProfile(this.Page.User.Identity.Name);
                string myGolfClub = profile.GolfClub;
                //Guid guid = new Guid(myGolfClub);
                //var manager = new CmsManager();
                //ICmsPage myPage = (ICmsPage)manager.GetPage(guid);
                list.Items.FindByValue(myGolfClub).Selected = true;
                  
                //list.Items.Add(new ListItem(myPage.MenuName, myPage.ID.ToString()));
      
            }
        }
      
        private Control FindControlRecursive(Control root, string id)
        {
            if (root.ID == id)
            {
                return root;
            }
      
            foreach (Control c in root.Controls)
            {
                Control t = FindControlRecursive(c, id);
                if (t != null)
                {
                    return t;
                }
            }
      
            return null;
        }
      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                MembershipUser user = UserManager.Default.GetUser();
      
                this.manageProfile.Mode = Telerik.Security.WebControls.ManageProfile.Modes.Edit;
                this.manageProfile.Username = user.UserName;
            
      
        }
      
        protected void cmdSaveUser_Command(object sender, CommandEventArgs e)
        {
            try
            {
                MembershipUser user = UserManager.Default.GetUser();
                this.manageProfile.SetProfileProperties(user.UserName);
                UserManager.Default.UpdateUser(user);
            }
            catch
            {
            }
        
    }
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Jun 2010
    Link to this post
    Hi Johnny,

    There is an object inside OnPreRender of your control which is null, but you are trying to use it. As i see there is no any check for null reference. You can put some if loops to escape null reference  and attach the code to VS debugger to see which object exactly trows the exception

    All the best,
    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
  6. Johnny
    Johnny avatar
    45 posts
    Registered:
    08 Mar 2009
    29 Jun 2010
    Link to this post
    Yes but it works in my public view but not in my admin view. Do I have to have all properties that I have in my public "manage account", in my admin "myProfile.aspx" file?

    I have checked my DB and there is no empty fields... Strange..
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jun 2010
    Link to this post
    Hi Johnny,

    Most probably one of the following objects

    • golfClubs
    • currentPage
    • childPages
    throws null reference exception. Add if loops to escape the null exceptions and attach your code to VS debugger to see from where the issue comes from as suggested in the previous reply to you. This will help you to narrow down the issue.
    Sincerely yours,
    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
  8. Ravishankar Baranwal
    Ravishankar Baranwal avatar
    19 posts
    Registered:
    18 Mar 2009
    08 Sep 2010
    Link to this post
    The user controle provided for the registration I have to customise it by adding some more fields so how does I can do this. What are the code files where we can make changes. If you provide some link or stuff will be appreciable.
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Sep 2010
    Link to this post
    Hi Ravishankar,

    The control is located under Sitefinity\UserControls\Login\CreateUserWizardControl.ascx. This is a user control, so you will be able to observe its code.

    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
  10. Ravishankar Baranwal
    Ravishankar Baranwal avatar
    19 posts
    Registered:
    18 Mar 2009
    08 Sep 2010
    Link to this post
    So, One more thing. When I have to do any other functionality in the page or need to create a page then we have to use the Visual studio for this. So, can you please let me know what are the benefit of sitefinity CMS, because every thing is going to be implemented through the User Controls. Please light some focus on this...
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Sep 2010
    Link to this post
    Hello Ravishankar,

    Pages are dynamic and created by Sitefinity, so you do not have to use VS. The functionality is added through UserControls, so you can easily use them for another project. Backend supports uploading of user and custom control which are automatically registered and you can use them on your pages. Through control's designer you can edit each public property without VS.

    Greetings,
    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
  12. Ravishankar Baranwal
    Ravishankar Baranwal avatar
    19 posts
    Registered:
    18 Mar 2009
    09 Sep 2010
    Link to this post
    Let me make my question more specific as given bellow.

    In Sitefinity, we have Registration control. Can I add more fields to this control from Sitefinity CMS? If no, please provide me a workaround where I don’t have to use Visual Studio.


  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Sep 2010
    Link to this post
    Hi Ravishankar Baranwal,

    If this is a control you cannot add fields. You can have a single property or ControlDesigner where you choose from some options and then render the entered data as multiple fields.

    Sincerely yours,
    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
  14. Ravishankar Baranwal
    Ravishankar Baranwal avatar
    19 posts
    Registered:
    18 Mar 2009
    10 Sep 2010
    Link to this post

    How can I provide user accounts feature where different users login their respective accounts and can see their own stuff selected in past.

  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Sep 2010
    Link to this post
    Hi Ravishankar,

    You can get the roles under which a given user belongs by using UserManager.GetCurrentUserRoles() method. This returns a string array containing the names of all the roles that the currently logged-on user. Then you can disable or hide some of the frond end functionality. For the backend each module has Permissions section that you can use to set rights for Role Provider roles.

    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
Register for webinar
15 posts, 1 answered