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

Forums / General Discussions / Edit User Profile

Edit User Profile

12 posts, 0 answered
  1. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    24 May 2010
    Link to this post

    i am trying to create a form to allow user to edit his/her own profile without log in to the sitefinity administration page. I am able to allow user to edit the address and phone information. But having problem to add the email field in the form. The data for the address and phone are in the telerik_UserMetaInfo table. How do I add the email data from the telerik_Users table. Here is the code I used in the ascx file. Thanks, ~Pik

    <cc1:ManageProfile ID="manageProfile" runat="server" Mode="edit" UsernameIfNoNames="false">

     

     

    <EditTemplate>

     

     

    <ol>

     

     

    <li>

     

     

    <asp:Label ID="lblAddress" runat="server" Text="Address" TargetID="Address"></asp:Label>

     

     

    <asp:TextBox ID="Address" runat="server"></asp:TextBox>

     

     

    </li>

     

     

    <li>

     

     

    <asp:Label ID="lblCity" runat="server" Text="City" TargetID="City"></asp:Label>

     

     

    <asp:TextBox ID="City" runat="server"></asp:TextBox>

     

     

    </li>

     

     

     

    <li>

     

     

    <asp:Label ID="lblState" runat="server" Text="State" TargetID="State"></asp:Label>

     

     

    <asp:TextBox ID="State" runat="server"></asp:TextBox>

     

     

    </li>

     

     

     

    <li>

     

     

    <asp:Label ID="lblZip" runat="server" Text="Zip Code" TargetID="Zip"></asp:Label>

     

     

    <asp:TextBox ID="Zip" runat="server"></asp:TextBox>

     

     

    </li>

     

     

     

    <li>

     

     

    <asp:Label ID="lblPhone" runat="server" Text="Phone" TargetID="Phone_Value"></asp:Label>

     

     

    <asp:TextBox ID="Phone_Value" runat="server"></asp:TextBox>

     

     

    </li>

     

     

    </ol>

     

     

    </EditTemplate>

     

     

     

    </

     

    cc1:ManageProfile>

     

     

     

    <

     

    asp:Label ID="ProfileMessage" runat="server" />

     

    <

     

    asp:LinkButton ID="cmdSaveUser" Text="Save" CommandName="Save" OnCommand="cmdSaveUser_Command" runat="server"></asp:

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 May 2010
    Link to this post
    Hello Pik Lee,

    Please take a look at this post phone and email aren't updated  where a similar problem was discussed. Email is a MembershipUser property and you cannot use ManageProfile to set it. You should get the user and call UserManager.Default.UpdateUser(user); to update the email property.

    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.
  3. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    24 May 2010
    Link to this post
    Thanks for the information.  I am still having problem. How do i edit the email and have it save to the db. Here is the code that I am using. Thanks.

       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);

                ProfileMessage.Visible = true;
                ProfileMessage.Text = "<font color='red'>Your information is updated.</font>";

            }
            catch
            {
               
            }
        }
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 May 2010
    Link to this post
    Hi Pik Lee,

    Get the MembershipUser object. the Memebrship user has get/set property - "Email" that you should use. finally call Membership.UpdateUser method.

    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.
  5. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    24 May 2010
    Link to this post
    Thanks again for the reply.  With the following code , I am able to update the email data.

                MembershipUser user = UserManager.Default.GetUser();
                user.Email = "someone@email.com";
                Membership.UpdateUser(user);

    However, when I try to use this following code. The email will not get updated.

                TextBox txtEmail = (TextBox)this.FindControl("Email");
                string uEmail = txtEmail.Text;
                MembershipUser user = UserManager.Default.GetUser();
                user.Email = uEmail;
                Membership.UpdateUser(user);

    What am I missing here? How do I get the "Email" from the form? Thanks.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 May 2010
    Link to this post
    Hi Pik Lee,

    In your form I do not see where you have declared a control with ID="Email" or how you are creating this control dynamically.

    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.
  7. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    25 May 2010
    Link to this post
    I added the following to the form.

    <asp:Label ID="lblEmail"  runat="server"  Text="Email" TargetID="Email"></asp:Label>
    <asp:TextBox ID="Email" runat="server"></asp:TextBox>

    Thanks, Pik
  8. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    25 May 2010
    Link to this post
    I figured it out. It was the location of the Email on the form that cause the problems.

    Thanks,
    Pik
  9. Tyler Smith
    Tyler Smith avatar
    7 posts
    Registered:
    03 Dec 2004
    27 Oct 2010
    Link to this post
    Hi Pik -

    We are trying to accomplish something similar to this and was wondering if you'd be wiling to share the code you came up with for allowing users to change their profile information from the public pages?

    Thanks!

    Greg
  10. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    27 Oct 2010
    Link to this post
    Greg,

    I implemented this function by creating a custom ascx file. Below is the code. Hope this help! ~Pik

    Ascx file:
    <cc1:ManageProfile ID="manageProfileEdit" runat="server" Mode="edit" UsernameIfNoNames="false">   <br>    <EditTemplate><br>    <fieldset id="UserUpdateProfile"><br>        <ol>   <br>            <li>   <br>                <asp:Label ID="lblAddress" runat="server" Text="Address: " TargetID="Address" CssClass="lblUserLabel"></asp:Label>   <br>                <asp:TextBox ID="Address" runat="server" width="350px"></asp:TextBox>   <br>            </li> <br>            <li>   <br>                <asp:Label ID="lblCity" runat="server" Text="City: " TargetID="City" CssClass="lblUserLabel"></asp:Label>   <br>                <asp:TextBox ID="City" runat="server" CssClass="txtUserText"></asp:TextBox>   <br>            </li><br>            <li>   <br>                <asp:Label ID="lblState" runat="server" Text="State: " TargetID="State" CssClass="lblUserLabel"></asp:Label>   <br>                <asp:DropDownList id="State" runat="server"><br>                <asp:ListItem >------ Select ------</asp:ListItem><br>                <asp:ListItem Value="AL">Alabama</asp:ListItem><br>                    <asp:ListItem Value="WY">Wyoming</asp:ListItem><br>            ...<br>                    </asp:DropDownList>  <br>            </li><br>            <li>   <br>                <asp:Label ID="lblZip" runat="server" Text="Zip Code: " TargetID="Zip" CssClass="lblUserLabel"></asp:Label>   <br>                <asp:TextBox ID="Zip" runat="server"></asp:TextBox><br>            </li><br>            <li>   <br>                <asp:Label ID="lblPhone" runat="server" Text="Phone: " TargetID="Phone_Value" CssClass="lblUserLabel"></asp:Label>   <br>                <asp:TextBox ID="Phone_Value" runat="server" CssClass="txtUserText"></asp:TextBox><br></li><br>        </ol>   <br>    </EditTemplate>   <br></cc1:ManageProfile>   <br>        <ol id="UserUpdateProfileEmail"><br>            <li>   <br>                <asp:Label ID="lblEmail"  runat="server"  Text="Email: " TargetID="Email" CssClass="lblUserLabel"></asp:Label><br>                <asp:TextBox ID="Email" runat="server" CssClass="txtUserText"></asp:TextBox><br>               <br>            </li><br>            <li><br>            <asp:Label ID="ProfileMessage" runat="server" /><br>            </li><br>            <li><br>            <asp:LinkButton ID="cmdSaveUser" Text="Save" CommandName="Save" OnCommand="cmdSaveUser_Command" runat="server" CssClass="btnUserProfileSubmit"></asp:LinkButton><br>            <asp:LinkButton ID="cmdCancelUser" Text="Cancel" CommandName="Cancel"  OnCommand="cmdCancelUser_Command" runat="server" CssClass="btnUserProfileCancel"></asp:LinkButton><br>            </li><br>        </ol><br>    </fieldset>

    here is the code behind the ascx file:
       protected void Page_Load(object sender, EventArgs e)<br>    {<br>        if (!this.Page.IsPostBack)<br>        {<br>            MembershipUser user = UserManager.Default.GetUser();<br>            this.manageProfileEdit.Mode = Telerik.Security.WebControls.ManageProfile.Modes.Edit;<br>            this.manageProfileEdit.Username = user.UserName;<br>            Email.Text = user.Email;<br>        }<br>    }<br><br>    protected void cmdSaveUser_Command(object sender, CommandEventArgs e)<br>    {<br>        try<br>        {<br>            string uEmail = Email.Text;<br>            MembershipUser userEmail = UserManager.Default.GetUser();<br>            userEmail.Email = uEmail;<br>            Membership.UpdateUser(userEmail);<br><br>            MembershipUser user = UserManager.Default.GetUser();<br>            UserManager.Default.UpdateUser(user);<br>            this.manageProfileEdit.SetProfileProperties(user.UserName);<br><br>            ProfileMessage.Visible = true;<br>            ProfileMessage.Text = "<font color='red'>Your information has been successfully updated. </font>";<br>        }<br>        catch<br>        {<br>            ProfileMessage.Visible = true;<br>            ProfileMessage.Text = "Contact Info";<br>        }<br>    }<br><br>    protected void cmdCancelUser_Command(object sender, CommandEventArgs e)<br>    {<br>        Response.Redirect("Whateverpage.aspx");<br>    }<br>
  11. Aruna
    Aruna avatar
    1 posts
    Registered:
    11 Jul 2012
    05 Oct 2012
    Link to this post
    Hi,
    I want to update the user's email Id.
    I have sitefinity verion 5.1.345.
    I ca methods to change password, but I am not able to get any method or any way to update the email id of the user.Can you please let me know the way to update the users email address in sitefinty through the coding.
    Thank You,
    Aruna
  12. Alex
    Alex avatar
    2 posts
    Registered:
    10 Nov 2014
    13 Nov 2014
    Link to this post
    Well at first your id isn't declared and second you haven't mentioned Id controller. How is it possible that your code could have been doing on it's own with dynamic controlling. 
Register for webinar
12 posts, 0 answered