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

Forums / Developing with Sitefinity / Front end editing of users profile

Front end editing of users profile

3 posts, 1 answered
  1. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    27 Jul 2010
    Link to this post
    Hi

    How do I let my front end user edit his profile details (eg Address)

    I've used the built in control Login / ManageProfile.

    Even when I do this with no customisation, it displays no data (neither the first nor last name)

    I've tried adding in a new ascx into EditTemplateUrl which contains the following

    <br>First Name: <asp:TextBox ID="FirstName"  runat="server" /><br>
    Last Name: <asp:TextBox ID="LastName" runat="server" /><br>
    Organisation Name: <asp:TextBox ID="OrganisationName" runat="server" /> <br>
    <asp:Button ID="Submit" runat="server" Text="Submit" />

    It displays, however the textbox's are not filled in.

    My ascx page contains only what you see above.... There is data being populated for the users (have heavily customised the Users.aspx page and added to profile to allow for extra fields eg OrganisationName).

    eg part of web.config profile

    <properties>
            <add name="FirstName"/>
            <add name="LastName"/>
            <add name="Position"/>
            <add name="Photo_Hidden"/>
            <add name="Photo" defaultValue="~/Sitefinity/Common/Images/defaultavatar.gif"/>
            <group name="InstantMessenger">
              <add name="IM_Type"/>
              <add name="IM_Value"/>
            </group>
            <group name="Phone">
              <add name="Value"/>
              <add name="Type"/>
            </group>
            <add name="OrganisationName"/>




  2. George
    George  avatar
    204 posts
    Registered:
    05 Sep 2006
    27 Jul 2010
    Link to this post
    Hi Dave,

    I think it will be better if you create your own Manage Profile control and customize it as needed.

    Here is an example based on the sample code that you posted earlier.

    CustomManageProfile.ascx

    <br>First Name: <asp:TextBox ID="FirstName"  runat="server" /><br>
    Last Name: <asp:TextBox ID="LastName" runat="server" /><br>
    Organisation Name: <asp:TextBox ID="OrganisationName" runat="server" /> <br>
    <asp:Button ID="Submit" runat="server" Text="Submit" />

    CustomManageProfile.ascx.cs

        protected void Page_Load(object sender, EventArgs e)
        {
        GetCurrentUserInfo();
        }
     
        private void GetCurrentUserInfo()
    {
     
            var userProfile = Profile.GetProfile(UserManager.GetCurrentUserName());
     
                if (userProfile != null)
                {
                    FirstName.Text = userProfile.FirstName;
            LastName.Text = userProfile.LastName;
            OrganisationName.Text = userProfile.OrganisationName;
                }
     
    }
     
        protected void Submit_Click(object sender, EventArgs e)
        {
         
            var userProfile = Profile.GetProfile(UserManager.GetCurrentUserName());
     
                if (userProfile != null)
                {
             
             userProfile.FirstName = FirstName.Text;
             userProfile.LastName = LastName.Text;
             userProfile.OrganisationName = OrganisationName.Text;
             userProfile.Save();
     
    }
        }

    Hope this was clear enough. If you need anything else, please let us know.

    Regards,

    George
    Answered
  3. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    27 Jul 2010
    Link to this post
    Hi George

    Many thanks that worked well.  I added in this:

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                GetCurrentUserInfo();
            }
        }

    Regards

    Dave
Register for webinar
3 posts, 1 answered