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

Forums / Developing with Sitefinity / Manage Users Control

Manage Users Control

2 posts, 0 answered
  1. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    22 Apr 2010
    Link to this post
    Trying to develop a control to manage users from front site of sitefinity. 
     I have a working model of the back-en user manager , however I cannot seem to figure out how to add news fields to the existing structure. For instance I would like to be able to update fields like isApproved from the membership table.

    Any Ideas ?

    here is my control so far.

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
     
    using Telerik.Cms;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Security;
    using Telerik.Cms.Web;
    using Telerik.Cms.Web.UI;
    using Telerik.Personalization;
    using Telerik.Web.UI;
    using Telerik.Security;
    using Telerik.Security.WebControls;
    public partial class UserControls_Custom_Controls_ManageUsers : System.Web.UI.UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            manageUsers.ModeChanged += new EventHandler(manageUsers_ModeChanged);
            manageUsers.CreatedRole += new RoleCreatedEventHandler(manageUsers_CreatedRole);
        }
     
        void manageUsers_CreatedRole(object sender, GlobalPermissionsEventArgs e)
        {
            if (UserManager.Default.RoleProvider.Name == e.RoleProviderName)
            {
                GlobalPermissions.Instance.SetPermissions(e.GlobalPermissions, 0, UserManager.Default.RoleProvider.Name, new string[] { e.Role });
            }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            manageUsers.AttachCommandPanel(usersCommands);
     
            if (!Page.IsPostBack)
            {
                if (Request.QueryString.Get("mode") != null
                    && Request.QueryString.Get("mode").Equals("new"))
                {
                    manageUsers.Mode = ManageUsers.Modes.Insert;
                }
     
                if (Request.QueryString.Get("action") != null &&
                    Request.QueryString.Get("action").Equals("profile") &&
                    Request.QueryString.Get("username") != null)
                {  // access to profile from Newsletter groups (CMS users)
                    string username = Request.QueryString.Get("username");
                    manageUsers.UserName = username;
                }
            }
            if (Membership.Providers.Count <= 1 || Roles.Providers.Count <= 1)
            {
                HtmlControl div = this.usersCommands.Container.FindControl("providersPanel") as HtmlControl;
                if (div != null)
                    div.Visible = false;
            }
        }
     
     
     
        void manageUsers_ModeChanged(object sender, EventArgs e)
        {
            switch (manageUsers.Mode)
            {
                case ManageUsers.Modes.List:
                   // this.ControlPanelTitle.InnerText = (string)GetLocalResourceObject("Users");
                    break;
                case ManageUsers.Modes.Insert:
                    {
                    //    this.ControlPanelTitle.InnerText = String.Format("{0} > {1}", (string)GetLocalResourceObject("Users"), (string)GetLocalResourceObject("CreateNew"));
                        SetFaqVisibility();
                        break;
                    }
                case ManageUsers.Modes.Edit:
                    {
                         
                   //     this.ControlPanelTitle.InnerText = String.Format("{0} > {1}", (string)GetLocalResourceObject("Users"), (string)GetLocalResourceObject("Edit"));
     
     
                        SetFaqVisibility();
                        break;
                    }
                case ManageUsers.Modes.Roles:
                   // this.ControlPanelTitle.InnerText = (string)GetLocalResourceObject("Roles");
                    break;
            }
        }
     
        protected void passwordRecoveryButton_Click(object sender, EventArgs e)
        {
            string newPassword = manageUsers.Manager.MembershipProvider.ResetPassword(manageUsers.UserName, "42");
            Telerik.Security.WebControls.ManageUsers.EditContainer editContainer = manageUsers.GetCurrentContainer() as Telerik.Security.WebControls.ManageUsers.EditContainer;
            if (editContainer != null)
            {
                Control passRecovery = editContainer.FindControl("passwordRecoveryButton");
                if (passRecovery != null)
                {
                    int index = editContainer.Controls.IndexOf(passRecovery);
     
                    Literal newPass = new Literal();
                    newPass.Text = "New password: ";
     
                    Label newNote = new Label();
                    newNote.Controls.Add(newPass);
                    Literal passLiteral = new Literal();
                    passLiteral.Text = newPassword;
                    HtmlGenericControl strong = new HtmlGenericControl("strong");
                    strong.Controls.Add(passLiteral);
     
                    newNote.Controls.Add(strong);
     
                    editContainer.Controls.AddAt(index + 1, newNote);
                }
            }
        }
     
        private void SetFaqVisibility()
        {
            Control container = manageUsers.GetCurrentContainer();
     
            if (container == null) return;
     
            HtmlGenericControl divFaq = container.FindControl("divFaq") as HtmlGenericControl;
     
            if (divFaq != null)
            {
                divFaq.Visible = Telerik.Personalization.PersonalizationManager.DefaultInstance.GetGlobalValue<bool>(Telerik.Personalization.GlobalSettingConstants.ShowFaq, true);
     
                if (divFaq.Visible)
                {
                    HtmlAnchor lnkHideFaq = container.FindControl("lnkHideFaq") as HtmlAnchor;
     
                    if (lnkHideFaq != null)
                    {
                        string script = string.Format(System.Globalization.CultureInfo.CurrentCulture, "javascript:Personalization.hideFaqSection('{0}')", divFaq.ClientID);
     
                        lnkHideFaq.Attributes.Add("onclick", script);
                    }
                }
            }
        }
    }

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ManageUsers.ascx.cs" Inherits="UserControls_Custom_Controls_ManageUsers" %>
    <%@ Register TagPrefix="cc1" Assembly="Telerik.Security" Namespace="Telerik.Security.WebControls" %>
    <%@ Register TagPrefix="cc1" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>
    <%@ Register TagPrefix="cc2" Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" %>
    <%@ Register TagPrefix="cc2" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>
     
    <cc1:ManageUsers runat="server" ID="manageUsers">
                    <ListTemplate>
                        <cc2:MessageControl runat="server" ID="message">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="messageText"></asp:Label>
                            </ItemTemplate>
                        </cc2:MessageControl>
                        <div class="ToolsAll">
                            <asp:LinkButton ID="createNew" CommandName="CreateNew" runat="server" CssClass="CmsButLeft new">
                                <strong class="CmsButRight light">
                                    <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:CreateUser %>" /></strong></asp:LinkButton>
                            <div class="searchItems">
                                <div class="searchInputs">
                                    <asp:Label ID="Label1" AssociatedControlID="SearchField" Text="<%$ Resources:SearchUsersBy %>"
                                        runat="server"></asp:Label>
                                    <asp:DropDownList ID="searchField" runat="server">
                                    </asp:DropDownList>
                                    <asp:Label ID="Label2" AssociatedControlID="SearchWords" Text="<%$ Resources:For %>"
                                        runat="server"></asp:Label>
                                    <asp:TextBox ID="searchWords" CssClass="searchString" runat="server"></asp:TextBox>
                                    <asp:Button ID="searchButton" CommandName="Search" Text="<%$ Resources:Search %>"
                                        runat="server" CssClass="searchButton" />
                                </div>
                            </div>
                            <div class="clear">
                                <!-- -->
                            </div>
                        </div>
                        <div class="workArea">
                            <h2 id="gridTitle" runat="server" class="gridTitle">
                                <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:AllUsers %>" /></h2>
                            <div class="groupActions" runat="server" id="groupActions">
                                <span class="cmstextlbl"><asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:SelectAndAction %>" /></span>
                                <asp:LinkButton runat="server" ID="unassignSelected" CssClass="unassign" />
                                <span class="cmstextlbl"> | </span>
                                <asp:LinkButton runat="server" ID="deleteSelected" Text="<%$ Resources:Delete %>" CssClass="delete" CommandName="DeleteSelected" OnClientClick="return confirm('Are you sure you want to delete this user?');" />
                                <span class="cmstextlbl">or</span>
                                <asp:DropDownList runat="server" ID="actionsList"></asp:DropDownList>
                            </div>
                            <asp:GridView ID="GridView1"  Width="100%" AllowPaging="true" AllowSorting="true" PageSize="20"
                                AutoGenerateColumns="false" GridLines="none" CssClass="listItems" runat="server">
                                <Columns>
                                    <asp:TemplateField ItemStyle-CssClass="check">
                                        <HeaderTemplate>
                                            <asp:CheckBox ID="checkAll" runat="server" /></HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox runat="server" ID="rowCheck" /></ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="UserName" SortExpression="UserName" HeaderText="Username"
                                        HeaderStyle-CssClass="GridHeader_SiteFinity">
                                        <ItemStyle CssClass="gridContentTitle" />
                                    </asp:BoundField>
                    <asp:BoundField DataField="isApproved"  HeaderText="Approved" HeaderStyle-CssClass="GridHeader_SiteFinity" />                               
                                    <asp:BoundField DataField="Email" SortExpression="Email" HeaderText="Email" HeaderStyle-CssClass="GridHeader_SiteFinity" />
                                    <asp:BoundField DataField="CreationDate" SortExpression="CreationDate" HeaderText="Creation Date"
                                        HeaderStyle-CssClass="GridHeader_SiteFinity" DataFormatString="{0:dd MMM yyyy, hh:mm}"
                                        HtmlEncode="false" />
                                    <asp:ButtonField ButtonType="Link" CommandName="Select" Text="Profile" AccessibleHeaderText="Profile">
                                        <ItemStyle CssClass="gridActions" />
                                    </asp:ButtonField>
                                    <asp:ButtonField ButtonType="Link" CommandName="Delete" Text="Delete" AccessibleHeaderText="Delete">
                                        <ItemStyle CssClass="gridActions delete" />
                                    </asp:ButtonField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </ListTemplate>
                    <InsertTemplate>
                        <cc2:MessageControl runat="server" ID="message">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="messageText"></asp:Label>
                            </ItemTemplate>
                        </cc2:MessageControl>
                        <div class="ToolsAll">
                            <div class="backWrapp">
                                <asp:LinkButton CommandName="Cancel" runat="server" ID="LinkButton2" CssClass="actions back"
                                    CausesValidation="false">
                                    <asp:Literal ID="Literal8" runat="server" Text="<%$ Resources:BackToUsers %>" /></asp:LinkButton>
                            </div>
                        </div>
                        <div class="workArea">
                            <div class="mainForm">
                                <p class="mand">
                                    *
                                    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:MandatoryFields %>" /></p>
                                <h3><asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:MembershipInfo %>" /></h3>
                                <fieldset class="userinfo set">
                                    <ol class="setIn">
                                        <li>
                                            <cc2:FieldLabel ID="lblUserName" runat="server" Text="<%$ Resources:Username %>"
                                                TargetID="UserName">
                                            </cc2:FieldLabel>
                                            <asp:TextBox ID="UserName" runat="server" ValidationGroup="CreateUser"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                                ErrorMessage="Username is required." ToolTip="Username is required." ValidationGroup="CreateUser"
                                                Display="Dynamic" SetFocusOnError="true" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal9" runat="server" Text="<%$ Resources:UsernameRequired %>" /></strong></asp:RequiredFieldValidator>
                                        </li>
                                        <li>
                                            <cc2:FieldLabel ID="lblPassword" runat="server" Text="<%$ Resources:Password %>"
                                                TargetID="Password">
                                            </cc2:FieldLabel>
                                            <asp:TextBox ID="Password" runat="server" TextMode="Password" ValidationGroup="CreateUser"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                                ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUser"
                                                Display="Dynamic" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal10" runat="server" Text="<%$ Resources:PasswordRequired %>" /></strong></asp:RequiredFieldValidator>
                                        </li>
                                        <li>
                                            <cc2:FieldLabel ID="lblConfirmPassword" runat="server" Text="<%$ Resources:ConfirmPassword %>"
                                                TargetID="ConfirmPassword">
                                            </cc2:FieldLabel>
                                            <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" ValidationGroup="CreateUser"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword"
                                                ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                                ValidationGroup="CreateUser" Display="Dynamic" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal11" runat="server" Text="<%$ Resources:ConfirmPassRequired %>" /></strong></asp:RequiredFieldValidator>
                                            <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                                ValidationGroup="CreateUser" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal12" runat="server" Text="<%$ Resources:PasswordMatch %>" /></strong></asp:CompareValidator>
                                        </li>
                                        <li>
                                            <cc2:FieldLabel ID="lblEmail" runat="server" Text="<%$ Resources:Email %>" TargetID="Email">
                                            </cc2:FieldLabel>
                                            <asp:TextBox ID="Email" runat="server" ValidationGroup="CreateUser"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Email"
                                                ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUser"
                                                Display="Dynamic" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:EmailRequired %>" /></strong></asp:RequiredFieldValidator>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email"
                                                Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="\S+@\S+\.\S+"
                                                ValidationGroup="CreateUser" CssClass="validMessage">
                                                <strong>
                                                    <asp:Literal ID="Literal14" runat="server" Text="<%$ Resources:EmailNotValid %>" /></strong></asp:RegularExpressionValidator>
                                        </li>
                                    </ol>
                                </fieldset>
                                <div class="bottom">
                                    <div>
                                        <!-- -->
                                    </div>
                                </div>
                                 
                                <cc1:ManageProfile ID="manageProfile" runat="server" Mode="Insert">
                                    <InsertTemplate>
                                        <h3><asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:UserDetails %>" /></h3>
                                        <fieldset class="userinfo set">
                                            <ol class="setIn">
                                                <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="lblPosition" runat="server" Text="Position" TargetID="Position">
                                                    </cc2:FieldLabel>
                                                    <asp:TextBox ID="Position" runat="server"></asp:TextBox>
                                                </li>                                           
                                            </ol>
                                        </fieldset>
                                        <div class="bottom">
                                            <div>
                                                <!-- -->
                                            </div>
                                        </div>
                                        <div class="more">
                                            <cc1:DropDownPanel ID="MoreOptionsPanel" runat="server" Text="<%$Resources:MoreAboutTheUser %>">
                                                <h3>Contact</h3>
                                                <fieldset class="userinfo set">
                                                <ol class="setIn">
                                                    <li>
                                                        <cc2:FieldLabel ID="lblPhone" runat="server" Text="Phone" TargetID="Phone_Value">
                                                        </cc2:FieldLabel>
                                                        <asp:TextBox ID="Phone_Value" runat="server"></asp:TextBox>
                                                  
                                                   <%-- <asp:DropDownList ID="Phone_Type" runat="server">
                                                        <asp:ListItem Text="Mobile" Value="Mobile" Selected="True" ></asp:ListItem>
                                                        <asp:ListItem Text="Office" Value="Office" ></asp:ListItem>
                                                        <asp:ListItem Text="Home" Value="Home" ></asp:ListItem>
                                                    </asp:DropDownList>--%>
                                                    </li>
                                                    <li>
                                                        <cc2:FieldLabel ID="lblIM_Value" runat="server" Text="Instant Messenger" TargetID="InstantMessenger_IM_Value">
                                                        </cc2:FieldLabel>
                                                        <asp:TextBox ID="InstantMessenger_IM_Value" runat="server"></asp:TextBox>
                                                    
                                                        <asp:DropDownList ID="InstantMessenger_IM_Type" runat="server">
                                                            <asp:ListItem Text="ICQ" Value="ICQ" Selected="True" />
                                                            <asp:ListItem Text="Skype" Value="Skype" />
                                                            <asp:ListItem Text="Google Talk" Value="Google Talk" />
                                                            <asp:ListItem Text="Windows Live (MSN)" Value="Windows Live (MSN)" />
                                                            <asp:ListItem Text="Yahoo! Messenger" Value="Yahoo! Messenger" />
                                                            <asp:ListItem Text="AIM" Value="AIM" />
                                                            <asp:ListItem Text="Jabber" Value="Jabber" />
                                                            <asp:ListItem Text="QQ" Value="QQ" />
                                                            <asp:ListItem Text="Other" Value="Other" />
                                                        </asp:DropDownList>
                                                    </li>
                                                </ol>
                                                </fieldset>
                                                <div class="bottom">
                                                    <div>
                                                        <!-- -->
                                                    </div>
                                                </div>
                                                <h3> Photo </h3>
                                                <fieldset class="userinfo set">
                                                    <div class="setIn">
                                                        <asp:HiddenField ID="Photo_Hidden" runat="server" ></asp:HiddenField>
                                                        <asp:Image ID="Photo" runat="server" ></asp:Image>
                                                        <cc2:ButtonSelector ID="ButtonSelector1" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" AssociatedControls="Photo_Hidden,Photo" ItemTemplatePath="~/Sitefinity/Admin/CmsAdmin/ButtonSelector.ascx" runat="server" cssclass="changePhotoSelector" ButtonText="<%$Resources:ChangePhoto%>" />
                                                    </div>
                                                </fieldset>
                                                <div class="bottom">
                                                    <div>
                                                        <!-- -->
                                                    </div>
                                                </div>
                                            </cc1:DropDownPanel>
                                        </div>
                                    </InsertTemplate>
                                         
                                </cc1:ManageProfile>
                                <h3>Roles</h3>
                                <fieldset class="roles meta set">
                                    <div class="setIn clearfix check">
                                        <p class="example">
                                            A role is a group of users associated with a set of user permissions.</p>
                                        <cc2:CheckBoxOrderList runat="server" ID="RolesList">
                                        </cc2:CheckBoxOrderList>
                                    </div>
                                </fieldset>
                                <div class="bottom">
                                    <div>
                                        <!-- -->
                                    </div>
                                </div>
                                <p class="button_area">
                                    <asp:LinkButton ID="SaveUser" Text="Save" CommandName="Save" runat="server" CssClass="CmsButLeft okdark"
                                        ValidationGroup="CreateUser"><strong class="CmsButRight dark">Create this user</strong></asp:LinkButton>
                                    <span>or</span>
                                    <asp:LinkButton ID="Button2" Text="Cancel" CommandName="Cancel" runat="server" CssClass="cmscclcmd"
                                        CausesValidation="false">Cancel</asp:LinkButton>
                                </p>
                            </div>
                            <div class="info" id="divFaq" runat="server">
                                <div class="infoBottom">
                                    <h3>Create Users FAQ</h3>
                                    <dl class="faq">
                                        <dt>Can I change the username?</dt>
                                        <dd>
                                            No, once a username is set, it is final. The only way to change the username is
                                            to register the user again and delete the old account.</dd>
                                        <dt>What are roles?</dt>
                                        <dd>
                                            Roles define groups of users associated with the same permissions. They also determine
                                            the parts of Sitefinity a user can view.</dd>
                                        <dt>Can I assign a user to more than one role?</dt>
                                        <dd>
                                            Yes, you can assign a user to as many roles as you wish.</dd>
                                        <dt>Can I move a user from one role to another later?</dt>
                                        <dd>
                                            Yes, you can do that any time. Just select and unselect the corresponding checkboxes.</dd>
                                        <dt>Can I change this user's password later?</dt>
                                        <dd>
                                            No, you can't do that. The user can log in later to change his/her password.</dd>
                                        <dt>Does the user receive an automatic e-mail with his/her credentials?</dt>
                                        <dd>
                                            Sorry, still N/A. You should inform them personally.</dd>
                                    </dl>
                                    <p class="hideAllFAQs">
                                        <a id="lnkHideFaq" href="javascript:void(0)" runat="server">Hide FAQs everywhere</a>
                                    </p>
                                </div>
                            </div>
                            <div class="clear width">
                            </div>
                        </div>
                    </InsertTemplate>
                    <EditTemplate>
                        <cc2:MessageControl runat="server" ID="message">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="messageText"></asp:Label>
                            </ItemTemplate>
                        </cc2:MessageControl>
                        <div class="ToolsAll">
                            <div class="backWrapp">
                                <asp:LinkButton CommandName="Cancel" runat="server" ID="back" CssClass="actions back"
                                    CausesValidation="false">Back to users</asp:LinkButton></div>
                        </div>
                        <div class="workArea">
                            <div class="mainForm">
                                <p class="mand">
                                    * Mandatory fields</p>
                                <h3>
                                    Membership Info</h3>
                                <fieldset class="userinfo set">
                                    <ol class="setIn">
                                        <li class="exField">
                                            <dl>
                                                <dt>Username</dt><dd class="readOnly"><asp:Literal ID="UserName" runat="server"></asp:Literal></dd>
                                                <dd class="example">
                                                    The username cannot be changed</dd>
                                            </dl>
                                        </li>
                                        <li class="exField">
                                            <dl>
                                                <dt>Approved</dt><dd class="check" > <asp:CheckBox runat="server" ID="isApproved" /></dd>
                                                 
        
                                            </dl>
                                        </li>
                                        <li>
                                            <cc2:FieldLabel ID="lblEmail" runat="server" Text="Email *" TargetID="Email">
                                            </cc2:FieldLabel>
                                            <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Email"
                                                ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUser"
                                                Display="Dynamic" CssClass="validMessage"><strong>E-mail cannot be empty!</strong></asp:RequiredFieldValidator>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="Email"
                                                Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="\S+@\S+\.\S+"
                                                ValidationGroup="CreateUser" CssClass="validMessage"><strong>The email format is invalid!</strong></asp:RegularExpressionValidator>
                                        </li>                                   
                                        <li class="newPass">
                                            <asp:LinkButton ID="passwordRecoveryButton" runat="server" Text="Reset password" OnClick="passwordRecoveryButton_Click" Tooltip="Click to automatically create a new password for this user." OnClientClick="return confirm('Are you sure you want to change the password for this user?');"/>
                                        </li>
                                    </ol>
                                </fieldset>
                                <div class="bottom">
                                    <div>
                                        <!-- -->
                                    </div>
                                </div>
                                <cc1:ManageProfile runat="server" ID="manageProfile" Mode="Edit">
                                    <EditTemplate>
                                        <h3>User Details</h3>
                                        <fieldset class="userinfo set">
                                            <ol class="setIn">
                                                <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="lblPosition" runat="server" Text="Position" TargetID="Position">
                                                    </cc2:FieldLabel>
                                                    <asp:TextBox ID="Position" runat="server"></asp:TextBox>
                                                </li>                                           
                                            </ol>
                                        </fieldset>
                                        <div class="bottom">
                                            <div>
                                                <!-- -->
                                            </div>
                                        </div>
                                        <div class="more">
                                            <cc1:DropDownPanel ID="MoreOptionsPanel" runat="server" Text="<%$Resources:MoreAboutTheUser %>">
                                                <h3> Contact </h3>
                                                <fieldset class="userinfo set">
                                                    <ol class="setIn">
                                                        <li>
                                                            <cc2:FieldLabel ID="lblPhone" runat="server" Text="Phone" TargetID="Phone_Value">
                                                            </cc2:FieldLabel>
                                                            <asp:TextBox ID="Phone_Value" runat="server"></asp:TextBox>
     
                                                        <%--    <asp:DropDownList ID="Phone_Type" runat="server">
                                                                <asp:ListItem Text="Mobile" Value="Mobile" Selected="True" ></asp:ListItem>
                                                                <asp:ListItem Text="Office" Value="Office" ></asp:ListItem>
                                                                <asp:ListItem Text="Home" Value="Home" ></asp:ListItem>
                                                            </asp:DropDownList>--%>
                                                        </li>
                                                        <li>
                                                            <cc2:FieldLabel ID="lblIM_Value" runat="server" Text="Instant Messenger" TargetID="InstantMessenger_IM_Value">
                                                            </cc2:FieldLabel>
                                                            <asp:TextBox ID="InstantMessenger_IM_Value" runat="server"></asp:TextBox>
     
                                                            <asp:DropDownList ID="InstantMessenger_IM_Type" runat="server">
                                                                <asp:ListItem Text="ICQ" Value="ICQ" Selected="True" />
                                                                <asp:ListItem Text="Skype" Value="Skype" />
                                                                <asp:ListItem Text="Google Talk" Value="Google Talk" />
                                                                <asp:ListItem Text="Windows Live (MSN)" Value="Windows Live (MSN)" />
                                                                <asp:ListItem Text="Yahoo! Messenger" Value="Yahoo! Messenger" />
                                                                <asp:ListItem Text="AIM" Value="AIM" />
                                                                <asp:ListItem Text="Jabber" Value="Jabber" />
                                                                <asp:ListItem Text="QQ" Value="QQ" />
                                                                <asp:ListItem Text="Other" Value="Other" />
                                                            </asp:DropDownList>
                                                        </li>
                                                    </ol>
                                                </fieldset>
                                                <div class="bottom">
                                                    <div>
                                                        <!-- -->
                                                    </div>
                                                </div>
                                                <h3> Photo </h3>
                                                <fieldset class="userinfo set">
                                                    <div class="setIn">
                                                        <asp:HiddenField ID="Photo_Hidden" runat="server" ></asp:HiddenField>
                                                        <asp:Image ID="Photo" runat="server" ></asp:Image>
                                                        <cc2:ButtonSelector ID="ButtonSelector1" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" AssociatedControls="Photo_Hidden,Photo" ItemTemplatePath="~/Sitefinity/Admin/CmsAdmin/ButtonSelector.ascx" runat="server" cssclass="changePhotoSelector" ButtonText="<%$Resources:ChangePhoto%>" />
                                                    </div>
                                                </fieldset>             
                                                <div class="bottom">
                                                    <div>
                                                        <!-- -->
                                                    </div>
                                                </div>
                                            </cc1:DropDownPanel>
                                        </div>
                                    </EditTemplate>
                                </cc1:ManageProfile>   
                                <h3>Roles</h3>
                                <fieldset class="roles meta set">
                                    <div class="setIn clearfix check">
                                        <p class="example">
                                            A role is a group of users associated with a set of user permissions.</p>
                                        <cc2:CheckBoxOrderList runat="server" ID="RolesList">
                                        </cc2:CheckBoxOrderList>
                                    </div>
                                </fieldset>
                                <div class="bottom">
                                    <div>
                                        <!-- -->
                                    </div>
                                </div>
                                <p class="button_area">
                                    <asp:LinkButton ID="Button1" Text="Save" CommandName="Save" runat="server" CssClass="CmsButLeft okdark"
                                        ValidationGroup="CreateUser"><strong class="CmsButRight dark">Save user info</strong></asp:LinkButton>
                                    <span>or</span>
                                    <asp:LinkButton ID="Button2" Text="Cancel" CommandName="Cancel" runat="server" CssClass="cmscclcmd"
                                        CausesValidation="false">Cancel</asp:LinkButton>
                                </p>
                            </div>
                            <div class="info" id="divFaq" runat="server">
                                <div class="infoBottom">
                                    <h3>User Profile FAQ</h3>
                                    <dl class="faq">
                                        <dt>Can I assign a user to more than one role?</dt>
                                        <dd>
                                            Yes, you can assign a user to as many roles as you wish.</dd>
                                        <dt>Can I move a user from one role to another later?</dt>
                                        <dd>
                                            Yes, you can do that any time. Just select and unselect the corresponding checkboxes.</dd>
                                        <dt>How I change this user's password?</dt>
                                        <dd>
                                            You can only change your own password. Click the My Profile link in the top right
                                            corner of the screen.
                                        </dd>
                                    </dl>
                                    <p class="hideAllFAQs">
                                        <a id="lnkHideFaq" href="javascript:void(0)" runat="server">Hide FAQs everywhere</a>
                                    </p>
                                </div>
                            </div>
                            <div class="clear">
                                <!-- -->
                            </div>
                        </div>
                    </EditTemplate>
                    <RolesTemplate>
                        <cc2:MessageControl runat="server" ID="message">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="messageText"></asp:Label>
                            </ItemTemplate>
                        </cc2:MessageControl>
                        <div class="workArea">
                            <div id="newRole">
                                <cc2:FieldLabel ID="lblNewRoleName" runat="server" Text="Create a role" TargetID="RoleName">
                                </cc2:FieldLabel>
                                <asp:TextBox runat="server" ID="RoleName"></asp:TextBox>
                                <asp:LinkButton ID="btnCreateRole" CommandName="CreateRole" runat="server" CssClass="CmsButLeft okdark"><strong class="CmsButRight dark">Create</strong></asp:LinkButton>
                                <p class="example">
                                    <strong>Example: </strong><q>Authors</q></p>
                            </div>
                            <div class="instruct">
                                <h3>
                                    What is a role?</h3>
                                <p>
                                    A role is a group of users associated with a set of user permissions.</p>
                            </div>
                            <asp:GridView ID="GridView1" AutoGenerateColumns="false" GridLines="none" CssClass="listItems"
                                runat="server">
                                <Columns>
                                    <asp:BoundField DataField="Name" HeaderText="Role" HeaderStyle-CssClass="GridHeader_SiteFinity">
                                        <ItemStyle CssClass="gridContentTitle" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="AssignedUsers" HeaderText="Assigned Users" HeaderStyle-CssClass="GridHeader_SiteFinity" />
                                    <asp:ButtonField ButtonType="Link" CommandName="Select" Text="View Users" AccessibleHeaderText="View Users">
                                        <ItemStyle CssClass="gridActions" Width="100px" />
                                    </asp:ButtonField>
                                    <asp:ButtonField ButtonType="Link" CommandName="Delete" Text="Delete" AccessibleHeaderText="Delete">
                                        <ItemStyle CssClass="gridActions delete" />
                                    </asp:ButtonField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </RolesTemplate>
                </cc1:ManageUsers>
                <cc1:UsersCommands runat="server" Visible="false" ID="usersCommands">
                    <LayoutTemplate>
                        <h2><asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:BrowseUsers %>" /></h2>
                        <div id="providersPanel" runat="server" class="provider SiteMapTools" >
                            <cc1:LabelToolTip HelpBoxCssClass="HelpBox" id="labelHelpBox1" runat="server" LabelMode="true" LabelTargetID="ProvidersList" LabelText="<%$Resources:ChangeProviders %>" ToolTipTitle="<%$Resources:Providers %>" ToolTipText="<%$Resources:ProviderDescription %>" AlternateText="<%$Resources:AboutProviders %>"></cc1:LabelToolTip>
                            <asp:DropDownList ID="ProvidersList" runat="server" AutoPostBack="true" />
                        </div
                        <strong id="all">
                            <asp:LinkButton runat="server" ID="cmdAllUsers" CommandName="AllUsers" Text="<%$ Resources:AllUsers %>"></asp:LinkButton></strong>
                        <h2>
                            <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:UsersByRole %>" /></h2>
                        <ul class="itemsList">
                            <asp:Repeater runat="server" ID="rolesRepeater">
                                <ItemTemplate>
                                    <li>
                                        <asp:LinkButton runat="server" ID="roleLink" CommandName="Select" CommandArgument='<%# Eval("Name")%>'><%# Eval("Name")%><span>(<%# Eval("AssignedUsers")%>)</span></asp:LinkButton></li>
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                        <div class="SiteMapTools">
                            <a class="coll" id="ddpCreateRole_lnk" href="javascript:togglePanel('ddpCreateRole')">
                                <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:CreateRole %>" /></a> | <asp:LinkButton
                                    runat="server" ID="cmdManageRoles" CommandName="ManageRoles" Text="<%$ Resources:ManageRoles %>"></asp:LinkButton>
                            <div class="ddlContent clearfix" id="ddpCreateRole_cnt" style="display: none;">
                                <cc2:FieldLabel ID="lblNewRoleName" runat="server" Text="Role name" TargetID="RoleName">
                                </cc2:FieldLabel>
                                <asp:TextBox runat="server" ID="RoleName"></asp:TextBox>
                                <asp:LinkButton ID="btnCreateRole" Text="Create" CommandName="CreateRole" runat="server"
                                    CssClass="CmsButLeft okdark"><strong class="CmsButRight dark">Create</strong></asp:LinkButton>
                                <div class="clear">
                                    <!-- -->
                                </div>
                            </div>
                        </div>
                        <h2 class="alph">
                            <asp:Literal ID="Literal4" runat="server" Text="Users by username" /></h2>
                        <cc1:AlphabetLinks runat="server" ID="alphabet" />
                        <div>
                             
                        </div>                  
                    </LayoutTemplate>
                </cc1:UsersCommands>
                 <script type="text/javascript">           
                function togglePanel(id){
                    var el1 = document.getElementById(id + "_cnt");
                    var el3 = document.getElementById(id + "_lnk");
                    if (el1){
                        if (el1.style.display == "none"){
                            el1.style.display = "block";
                            el3.className = "ex";
                        } else {
                            el1.style.display = "none";
                            el3.className = "coll";
                        }
                    }
                }
                </script>
            </div>
        </div>

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Apr 2010
    Link to this post
    Hi Aaron,

    You could subscribe for the events of the manageUsers control in OnInit get the user and set the isApproved value. Generally you have a CheckBox control which value is not used and the status of the user cannot be persisted.

    • CreatingUser
    • CreatedUser
    • UpdatingUser
    • UpdatedUser
    • DeletingUser
    • DeletedUser
    The line below just gets the property value from the MembershipUser and it can be used to only for displaying the value

    <asp:BoundField DataField="isApproved" SortExpression="isApproved" HeaderText="isApproved" />


    You could update the value of the checkbox as shown below

    void manageUsers_UpdatedUser(object sender, EventArgs e)
    {
        Telerik.Security.WebControls.ManageUsers.EditContainer editContainer = manageUsers.GetCurrentContainer() as Telerik.Security.WebControls.ManageUsers.EditContainer;
        if (editContainer != null)
        {
            var cb = editContainer.FindControl("isApproved") as CheckBox;
             // here work with MembershipUser class.
        }
    }


    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.
2 posts, 0 answered