More in this section

Forums / Developing with Sitefinity / Manage Users from front-end?

Manage Users from front-end?

19 posts, 1 answered
  1. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    29 Jul 2009
    Link to this post
    I would like to develop the ability to manage user and role information from the front-end of Sitefinity. We already use multiple providers so you can see why I might need to do this. 

    I would like something similar to what is setup in Sitefinity backend administration, but having it on the frontend would keep me from having to creating users with seperate accounts in the Sitefinity provider.

    How could I emplement this, any ideas?


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jul 2009
    Link to this post
    Hi Aaron,

    In the backend we use ManageUsers control. You can use the same control in your frontend inplementation. Since we use Membership, Role and Profile providers you can use each Required Provider Member in your logic.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    30 Jul 2009
    Link to this post
    Ok, I have tried using the ManageUsers control exactly like in the sitefinity page found at ~\Sitefinity\Admin\CmsAdmin\Users.aspx but I get this error on page load.

    The resource object with key 'Users' was not found.

    My guess this page is inheriting properties that my new page is not. 
    Can someone show me how to fix this?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2009
    Link to this post
    Hello Aaron,

    It seem that your user control does not have access to the local resources used for localization. To fix this in your control template instead of having literals like this:

    <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Users %>" /> 

    You can just type in the text. Or just copy the file ~/Sitefinity/Admin/CmsAdmin/App_LocalResources/Users.aspx.resx  to the folder of your custom control and give it the same name. For example if your custom user control is ~/UserControls/MyCustomControl.ascx, copy and rename the above mentioned resource file like that ~/UserControls/App_LocalResources/MuCustomControl.ascx.resx

    This should do the trick. If you have more questions, please feel free to contact us.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    30 Jul 2009
    Link to this post
    Wow quick response!  Thanks so much
    Still having issues..

    I have done what you suggested.  In fact I just copied the :
    ~\Sitefinity\Admin\CmsAdmin\Users.aspx
    ~\Sitefinity\Admin\CmsAdmin\Users.aspx.cs
    ~\Sitefinity\Admin\CmsAdmin\App_LocalResources\Users.aspx.resx

    to my usercontrol directory, renamed the control to MyUsers, made appropriate reference changes needed and added it to the web.config.

    so I now have:
    ~\UserControls\Testing\MyUsers.aspx
    ~\UserControls\Testing\MyUsers.aspx.cs
    ~\UserControls\Testing\App_LocalResources\MyUsers.aspx.resx

    Here is the errors I'm having on adding the MyUsers custom control to my page.

    Server Error in '/' Application.

    Type 'ASP.usercontrols_testing_myusers_aspx' does not inherit from 'System.Web.UI.UserControl'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Type 'ASP.usercontrols_testing_myusers_aspx' does not inherit from 'System.Web.UI.UserControl'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Type 'ASP.usercontrols_testing_myusers_aspx' does not inherit from 'System.Web.UI.UserControl'.]
       System.Web.UI.Util.CheckAssignableType(Type baseType, Type type) +8679088
       System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +85
       System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(String virtualPath, Type requiredBaseType) +30
       Telerik.Cms.Data.WebControlBase.LoadControl(TemplateControl template, Control& control) +71
       Telerik.Cms.Data.WebControlBase.LoadControl(TemplateControl template) +27
       Telerik.Cms.Data.WebControlBase.LoadControl() +12
       Telerik.Cms.Data.StagedPage.AddControl(String containerId, String url, Int32 ordinal, String controlId) +88
       Telerik.Cms.Data.StagedPage.AddControl(String containerId, String url, String controlId) +44
       Telerik.Cms.Web.UI.ToolBar.AddContol(String controlName, String zoneId, Int32 ordinal) +388
       Telerik.Cms.Web.UI.Toolbox.Button_Command(Object sender, CommandEventArgs e) +249
       System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082




    so I changed the inheritance in the code-behind file from:
         public partial class Admin_CmsAdmin_Users : AdminPage
    To
         public partial class Admin_CmsAdmin_Users : UserControl

    Then I get the error:

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0115: 'Admin_CmsAdmin_Users.MenuItemName': no suitable method found to override

    Source Error:

    Line 22: public partial class Admin_CmsAdmin_Users : UserControl
    Line 23: {
    Line 24:     public override string MenuItemName
    Line 25:     {
    Line 26:         get { return "admin_users"; }

    Source File: f:\KYPartnership_EARS_SF\UserControls\Testing\MyUsers.aspx.cs    Line: 24

    I will post the actual files in my next post


  6. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    30 Jul 2009
    Link to this post
    <%@ Page Language="C#" MasterPageFile="~/Sitefinity/Admin/Admin.master" AutoEventWireup="true" Inherits="Admin_CmsAdmin_Users" CodeFile="~/UserControls/Testing/MyUsers.aspx.cs" %> 
    <%@ 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" %> 
     
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"
        <div id="main"
            <div class="in"
                <div class="ContorlPanelTitle"
                    <h1 id="ControlPanelTitle" runat="server"
                        <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Users %>" /></h1
                </div> 
                <div id="ControlPanelMessage" class="ControlPanelMessage" runat="server" style="display: none"
                    &nbsp;</div> 
                <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">&nbsp;|&nbsp;</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" 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="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"
                                <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> 
                                                <li>  
                                                    <cc2:FieldLabel ID="lblPasswordQuestion" runat="server" Text="PasswordQuestion" TargetID="PasswordQuestion"
                                                    </cc2:FieldLabel> 
                                                    <asp:TextBox ID="PasswordQuestion" runat="server"></asp:TextBox> 
                                                </li>  
                                                 <li> 
                                                    <cc2:FieldLabel ID="lblOffice" Visible="True" runat="server" Text="Office" TargetID="Office"
                                                    </cc2:FieldLabel> 
                                                    <asp:DropDownList ID="OfficeList" runat="server"  AutoPostBack ="True" OnLoad="LoadOffices" OnTextChanged="OfficeList_OnTextChanged" OnSelectedIndexChanged="OfficeList_OnSelectedIndexChanged"  Height ="23px"></asp:DropDownList> 
                                                    <asp:TextBox ID="Office" runat="server" Visible="false"></asp:TextBox> 
                                                </li>    
                                                <li> 
                                                    <cc2:FieldLabel ID="lblOfficeName" runat="server" Text="OfficeName" TargetID="OfficeName" Visible="false"
                                                    </cc2:FieldLabel> 
                                                    <asp:TextBox ID="OfficeName" runat="server" OnTextChanged="OfficeName_onTextChanged" Visible="false" ></asp:TextBox> 
                                                     
                                                </li>  
                                                <li> 
                                                     
                                                     
                                                </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"
                                        <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> 
                                <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> 
                                    <class="hideAllFAQs"
                                        <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"
                                <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> 
                                            <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>    
                                                <li>  
                                                    <cc2:FieldLabel ID="lblPasswordQuestion" runat="server" Text="PasswordQuestion" TargetID="PasswordQuestion"
                                                    </cc2:FieldLabel> 
                                                    <asp:TextBox ID="PasswordQuestion" runat="server"></asp:TextBox> 
                                                </li>                                              
                                                 <li> 
                                                    <cc2:FieldLabel ID="lblOffice" Visible="True" runat="server" Text="Office" TargetID="Office"
                                                    </cc2:FieldLabel> 
                                                    <asp:DropDownList ID="OfficeList" runat="server"  AutoPostBack ="True" OnLoad="LoadOffices" OnTextChanged="OfficeList_OnTextChanged" OnSelectedIndexChanged="OfficeList_OnSelectedIndexChanged"  Height ="23px"></asp:DropDownList> 
                                                    <asp:TextBox ID="Office" runat="server" Visible="false"></asp:TextBox> 
                                                </li>    
                                                <li> 
                                                    <cc2:FieldLabel ID="lblOfficeName" runat="server" Text="OfficeName" TargetID="OfficeName" Visible="false"
                                                    </cc2:FieldLabel> 
                                                    <asp:TextBox ID="OfficeName" runat="server" OnTextChanged="OfficeName_onTextChanged" Visible="false" ></asp:TextBox> 
                                                     
                                                </li>                                     
                                                <li> 
                                                     
                                                     
                                                </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 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"
                                        <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> 
                                <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> 
                                    <class="hideAllFAQs"
                                        <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> 
                                <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> 
                <div class="clear width"
                    <!-- --> 
                </div> 
            </div> 
        </div> 
        <div id="subnav"
            <div class="in"
     
                <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> 
     
                <cc1:UsersCommands runat="server" 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"
                            <class="coll" id="ddpCreateRole_lnk" href="javascript:togglePanel('ddpCreateRole')"
                                <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:CreateRole %>" /></a>&nbsp;|&nbsp;<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> 
            </div> 
        </div> 
        <div class="clear width"
            <!-- --> 
        </div> 
    </asp:Content> 
     

  7. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    30 Jul 2009
    Link to this post
    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 System.Data.SqlClient; 
    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 Admin_CmsAdmin_Users : AdminPage 
        public override string MenuItemName 
        { 
            get { return "admin_users"; } 
        } 
     
        public override int RightsRequired 
        { 
            get 
            { 
                return GlobalRights.ManageUsers; 
            } 
        } 
     
        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); 
     
           HtmlControl ctl = this.Page .FindControl ("Office"as HtmlControl; 
                if (ctl != null
                    Response.Write(ctl.NamingContainer.ToString ()); 
             
     
            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
            } 
        } 
        public void OfficeList_OnTextChanged(object sender, EventArgs e) 
        { 
            ////TextBox office; 
            //DropDownList dd = new DropDownList(); 
            //dd = ((DropDownList)sender); 
            ////office = ((TextBox)dd.Parent.FindControl ("OfficeName")); 
            //dd.ClearSelection(); 
            ////office.Text = dd.SelectedValue.ToString(); 
            //Response.Write (" on text change "); 
            //DropDownList dd = new DropDownList(); 
            //dd = ((DropDownList)sender); 
        
     
        } 
        public void OfficeList_OnSelectedIndexChanged(object sender, EventArgs e) 
        { 
              
            ListItem li; 
            //li.Selected = true; 
            //Response.Write (dd.SelectedValue .ToString () +  "  li:" + li.Value .ToString ()); 
            TextBox office; 
            DropDownList dd = new DropDownList(); 
            dd = ((DropDownList)sender); 
            li = dd.SelectedItem ; 
     
            dd.ClearSelection (); 
            dd.SelectedValue =li.Value; 
            TextBox officeID = ((TextBox)dd.Parent.FindControl ("Office")); 
            office = ((TextBox)dd.Parent.FindControl ("OfficeName")); 
            office.Text = dd.SelectedItem.Text; 
            officeID.Text = li.Value ; 
            //Response.Write (" on index change "); 
             
     
        } 
        public void OfficeName_onTextChanged(object sender, EventArgs e) 
        { 
            //ListItem li; 
             
             
            //TextBox office; 
            //TextBox officeID; 
            //DropDownList dd; 
            //office = ((TextBox)sender); 
            //dd = ((DropDownList)office.Parent.FindControl ("OfficeList")); 
            //officeID = ((TextBox)office.Parent.FindControl ("Office")); 
            //dd.ClearSelection(); 
            //li = dd.Items .FindByText (office.Text.ToString ()); 
            //li.Selected = true; 
            //dd.SelectedValue = li.Value ; 
            //officeID.Text  = li.Value ; 
            //Response.Write ("  li:" + li.Value .ToString ()); 
     
             
         
         
        } 
     
        public void LoadOffices(object sender,EventArgs e) 
        { 
     
             
            string[] value; 
            value =  Roles.GetAllRoles(); 
            DropDownList dd = new DropDownList(); 
            dd = ((DropDownList)sender); 
            TextBox office; 
            if(dd.Items.Count == 0) 
            { 
                
            //DropDownList dd = new DropDownList(); 
            //dd = ((DropDownList)sender); 
            office = ((TextBox)dd.Parent.FindControl ("OfficeName")); 
             
     
            //DropDownList officeDD; 
                SqlConnection con; 
                SqlCommand cmdSelect; 
                SqlDataReader sqlReader; 
                String query; 
            //    officeDD = new DropDownList(); 
                 
                 
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["CCRREARSConnectionString"].ConnectionString); 
                
     
           // ListItem first = new ListItem("Change Office"); 
            //first.Selected = true; 
             
            //dd.Items .Add(first); 
     
     
     
             
     
            for(int i =1;i<value.Length ;i++) 
            { 
                 
                if (value[i].Contains("Office:")) 
                { 
     
                try 
                { 
                    con.Open (); 
                    SqlParameter param = new SqlParameter("CCRR", SqlDbType.VarChar); 
                    param.Value = value[i].Substring (7); 
                    cmdSelect = new SqlCommand("Select Id,CCRR from ccrr_names Where CCRR = @CCRR", con); 
                    cmdSelect.Parameters.Add(param);  
                    sqlReader = cmdSelect.ExecuteReader(); 
                    sqlReader.Read (); 
                    if (sqlReader.HasRows) 
                    { 
                       ListItem li = new ListItem(); 
                       li.Text = sqlReader.GetValue (1).ToString (); 
                       li.Value = sqlReader.GetValue(0).ToString (); 
                        if(office.Text.ToString() == li.Text.ToString() ) 
                        { 
                            li.Selected = true
                             
                        } 
                        dd.Items.Add(li); 
                    } 
                    sqlReader.Close(); 
                } 
                catch(Exception e2) 
                { 
                 
                    Response.Write (e2.Message ); 
                } 
     
                con.Close(); 
     
                 
     
                     
                    
                         
                } 
                     
            } 
                 
            } 
     
        } 
        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 == nullreturn
     
            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); 
                    } 
                } 
            } 
        } 

  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2009
    Link to this post
    Hi Aaron,

    Тhank you for getting back to me.

    I think that you are misinterpreting the ~/Sitefinity/Admin/CmsAdmin/Users.aspx page for an user control (.ascx). What Ivan has proposed in his first post was to see how the Manage Users control was used in that page and then wrap the Manage Users control to your custom user control (.ascx). Then you will be able to upload it to Sitefinity and use it on CMS pages. You easily just copy the content of the .aspx page into a .ascx user control. This will allow you to use control on the public side. However you will also have to define the look and feel, and styles of the control. Attached is the extracted functionality of the Manage Users control, however with no styling or layout. You would get this result by simply copy/pasting the code.

    Also make sure you will restrict access to the page where you will have this control only to users responsible for managing your members.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
    Answered
  9. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    31 Jul 2009
    Link to this post
    WOW THANKS!
      This gives me exactly what I need.  I have experience with object oriented programing but as you might have guess I am very new to .net web applications.  You were right I did not understand the concept of wrapping the control. Now I just have to customize it to our provider/membership, profile and then secure it.

    I think a lot of other people will find this useful.


  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    31 Jul 2009
    Link to this post
    Hello Aaron,

    We are more than glad to help our community. When you finish up with the implementation of the public users management control maybe you can share it with the community. As you suggested it will help out other people looking for the same implementation.

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  11. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    31 Jul 2009
    Link to this post
    Ok,
         For my implementation I'd like to programatically specify the provider but I can't figure out how to filter the gridview1 results.  (besides using the drop down, which I will be removing from my custom control, because I don't want public users to see other provider information)

    any suggestions?
  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Aug 2009
    Link to this post
    Hello Aaron,

    Currently the manage users class uses default ASP.NET GridView for filtering data. This default grid view supports two types of filtering data - by query string, or by DropDownList. You can look onto how to filter the ASP.NET GridView.

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  13. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    03 Aug 2009
    Link to this post
    Ok I figured out how to load a custom provider first. 
    I used the set providerName member of the manageusers class on page load.
    that was simple enough.

        protected void Page_Load(object sender, EventArgs e)
        {
         .
         .
         .
            manageUsers.ProviderName = "customProvider";
         .
         .
         }
  14. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    06 Aug 2009
    Link to this post
    Well.... Progressing along .... Here is my current issue.

    Everything seems to be working fine except, when I go to edit a members profile. 
    The fields are displaying and drawing data from database fine, but any changes are not saved. 

    * side note.  I have my custom profile fields setup in my backend sitefinity cmsAdmin Users.ascx and they are updating fine. So I don't think that it is an web.config or database issue.

    * If I try to edit a profile from the sitefinity provider the changes ARE saved.

    Any thoughts?

    Here is the .ascx and code behind code

    1 <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ManageUsers.ascx.cs" Inherits="UserControls_Custom_Controls_ManageUsers" %> 
    2 <%@ Register TagPrefix="cc1" Assembly="Telerik.Security" Namespace="Telerik.Security.WebControls" %> 
    3 <%@ Register TagPrefix="cc1" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %> 
    4 <%@ Register TagPrefix="cc2" Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" %> 
    5 <%@ Register TagPrefix="cc2" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %> 
    6 <cc2:MessageControl runat="server" ID="msgControl"
    7                         <ItemTemplate> 
    8                             <asp:Label runat="server" ID="messageText"></asp:Label> 
    9                         </ItemTemplate> 
    10 </cc2:MessageControl> 
    11 <cc1:ManageUsers runat="server" ID="manageUsers"
    12                 <ListTemplate> 
    13                     <cc2:MessageControl runat="server" ID="message"
    14                         <ItemTemplate> 
    15                             <asp:Label runat="server" ID="messageText"></asp:Label> 
    16                         </ItemTemplate> 
    17                     </cc2:MessageControl> 
    18                     <div class="ToolsAll"
    19                         <asp:LinkButton ID="createNew" CommandName="CreateNew" runat="server" CssClass="CmsButLeft new"
    20                             <strong class="CmsButRight light"
    21                                 <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:CreateUser %>" /></strong></asp:LinkButton> 
    22                         <div class="searchItems"
    23                             <div class="searchInputs"
    24                                 <asp:Label ID="Label1" AssociatedControlID="SearchField" Text="<%$ Resources:SearchUsersBy %>" 
    25                                     runat="server"></asp:Label> 
    26                                 <asp:DropDownList ID="searchField" runat="server"
    27                                 </asp:DropDownList> 
    28                                 <asp:Label ID="Label2" AssociatedControlID="SearchWords" Text="<%$ Resources:For %>" 
    29                                     runat="server"></asp:Label> 
    30                                 <asp:TextBox ID="searchWords" CssClass="searchString" runat="server"></asp:TextBox> 
    31                                 <asp:Button ID="searchButton" CommandName="Search" Text="<%$ Resources:Search %>" 
    32                                     runat="server" CssClass="searchButton" /> 
    33                             </div> 
    34                         </div> 
    35                         <div class="clear"
    36                             <!-- --> 
    37                         </div> 
    38                          
    39                          
    40                          
    41                          
    42                          
    43                          
    44                          
    45                          
    46                          
    47                     </div> 
    48                     <div class="workArea"
    49                         <h2 id="gridTitle" runat="server" class="gridTitle"
    50                             <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:AllUsers %>" /></h2
    51                         <div class="earsgroupActions" runat="server" id="groupActions"
    52                             <span class="cmstextlbl"><asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:SelectAndAction %>" /></span
    53                             <asp:LinkButton runat="server" ID="unassignSelected" CssClass="unassign" /> 
    54                             <span class="cmstextlbl">&nbsp;|&nbsp;</span> 
    55                             <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?');" /> 
    56                             <span class="cmstextlbl">or</span> 
    57                             <asp:DropDownList runat="server" ID="actionsList"></asp:DropDownList> 
    58                         </div> 
    59                         <asp:GridView ID="GridView1" AllowPaging="true" AllowSorting="true" PageSize="20" 
    60                             AutoGenerateColumns="false" GridLines="none" CssClass="listItems" runat="server"
    61                             <Columns> 
    62                                 <asp:TemplateField ItemStyle-CssClass="check"
    63                                     <HeaderTemplate> 
    64                                         <asp:CheckBox ID="checkAll" runat="server" /></HeaderTemplate
    65                                     <ItemTemplate> 
    66                                         <asp:CheckBox runat="server" ID="rowCheck" /></ItemTemplate
    67                                 </asp:TemplateField> 
    68                                 <asp:BoundField DataField="UserName" SortExpression="UserName" HeaderText="Username" 
    69                                     HeaderStyle-CssClass="GridHeader_SiteFinity"
    70                                     <ItemStyle CssClass="gridContentTitle" /> 
    71                                 </asp:BoundField> 
    72                                 <asp:BoundField DataField="Email" SortExpression="Email" HeaderText="Email" HeaderStyle-CssClass="GridHeader_SiteFinity" /> 
    73                                 <asp:BoundField DataField="CreationDate" SortExpression="CreationDate" HeaderText="Creation Date" 
    74                                     HeaderStyle-CssClass="GridHeader_SiteFinity" DataFormatString="{0:dd MMM yyyy, hh:mm}" 
    75                                     HtmlEncode="false" /> 
    76                                 <asp:ButtonField ButtonType="Link" CommandName="Select" Text="Profile" AccessibleHeaderText="Profile"
    77                                     <ItemStyle CssClass="gridActions" /> 
    78                                 </asp:ButtonField> 
    79                                 <asp:ButtonField ButtonType="Link" CommandName="Delete" Text="Delete" AccessibleHeaderText="Delete"
    80                                     <ItemStyle CssClass="gridActions delete" /> 
    81                                 </asp:ButtonField> 
    82                             </Columns> 
    83                         </asp:GridView> 
    84                     </div> 
    85                 </ListTemplate> 
    86                 <InsertTemplate> 
    87                     <cc2:MessageControl runat="server" ID="message"
    88                         <ItemTemplate> 
    89                             <asp:Label runat="server" ID="messageText"></asp:Label> 
    90                         </ItemTemplate> 
    91                     </cc2:MessageControl> 
    92                     <div class="ToolsAll"
    93                         <div class="backWrapp"
    94                             <asp:LinkButton CommandName="Cancel" runat="server" ID="LinkButton2" CssClass="actions back" 
    95                                 CausesValidation="false"
    96                                 <asp:Literal ID="Literal8" runat="server" Text="<%$ Resources:BackToUsers %>" /></asp:LinkButton> 
    97                         </div> 
    98                     </div> 
    99                     <div class="workArea"
    100                         <div class="mainForm"
    101                             <class="mand"
    102                                 * 
    103                                 <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:MandatoryFields %>" /></p
    104                             <h3><asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:MembershipInfo %>" /></h3
    105                             <fieldset class="userinfo set"
    106                                 <ol class="setIn"
    107                                     <li> 
    108                                         <cc2:FieldLabel ID="lblUserName" runat="server" Text="<%$ Resources:Username %>" 
    109                                             TargetID="UserName"
    110                                         </cc2:FieldLabel> 
    111                                         <asp:TextBox ID="UserName" runat="server" ValidationGroup="CreateUser"></asp:TextBox> 
    112                                         <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
    113                                             ErrorMessage="Username is required." ToolTip="Username is required." ValidationGroup="CreateUser" 
    114                                             Display="Dynamic" SetFocusOnError="true" CssClass="validMessage"
    115                                             <strong> 
    116                                                 <asp:Literal ID="Literal9" runat="server" Text="<%$ Resources:UsernameRequired %>" /></strong></asp:RequiredFieldValidator> 
    117                                     </li> 
    118                                     <li> 
    119                                         <cc2:FieldLabel ID="lblPassword" runat="server" Text="<%$ Resources:Password %>" 
    120                                             TargetID="Password"
    121                                         </cc2:FieldLabel> 
    122                                         <asp:TextBox ID="Password" runat="server" TextMode="Password" ValidationGroup="CreateUser"></asp:TextBox> 
    123                                         <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
    124                                             ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUser" 
    125                                             Display="Dynamic" CssClass="validMessage"
    126                                             <strong> 
    127                                                 <asp:Literal ID="Literal10" runat="server" Text="<%$ Resources:PasswordRequired %>" /></strong></asp:RequiredFieldValidator> 
    128                                     </li> 
    129                                     <li> 
    130                                         <cc2:FieldLabel ID="lblConfirmPassword" runat="server" Text="<%$ Resources:ConfirmPassword %>" 
    131                                             TargetID="ConfirmPassword"
    132                                         </cc2:FieldLabel> 
    133                                         <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" ValidationGroup="CreateUser"></asp:TextBox> 
    134                                         <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword" 
    135                                             ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required." 
    136                                             ValidationGroup="CreateUser" Display="Dynamic" CssClass="validMessage"
    137                                             <strong> 
    138                                                 <asp:Literal ID="Literal11" runat="server" Text="<%$ Resources:ConfirmPassRequired %>" /></strong></asp:RequiredFieldValidator> 
    139                                         <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" 
    140                                             ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." 
    141                                             ValidationGroup="CreateUser" CssClass="validMessage"
    142                                             <strong> 
    143                                                 <asp:Literal ID="Literal12" runat="server" Text="<%$ Resources:PasswordMatch %>" /></strong></asp:CompareValidator> 
    144                                     </li> 
    145                                     <li> 
    146                                         <cc2:FieldLabel ID="lblEmail" runat="server" Text="<%$ Resources:Email %>" TargetID="Email"
    147                                         </cc2:FieldLabel> 
    148                                         <asp:TextBox ID="Email" runat="server" ValidationGroup="CreateUser"></asp:TextBox> 
    149                                         <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Email" 
    150                                             ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUser" 
    151                                             Display="Dynamic" CssClass="validMessage"
    152                                             <strong> 
    153                                                 <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:EmailRequired %>" /></strong></asp:RequiredFieldValidator> 
    154                                         <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email" 
    155                                             Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="\S+@\S+\.\S+" 
    156                                             ValidationGroup="CreateUser" CssClass="validMessage"
    157                                             <strong> 
    158                                                 <asp:Literal ID="Literal14" runat="server" Text="<%$ Resources:EmailNotValid %>" /></strong></asp:RegularExpressionValidator> 
    159                                     </li> 
    160                                 </ol> 
    161                             </fieldset> 
    162                             <div class="bottom"
    163                                 <div> 
    164                                     <!-- --> 
    165                                 </div> 
    166                             </div> 
    167                              
    168                             <cc1:ManageProfile ID="manageProfile" runat="server" Mode="Insert"
    169                                 <InsertTemplate> 
    170                                     <h3><asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:UserDetails %>" /></h3
    171                                     <fieldset class="userinfo set"
    172                                         <ol class="setIn"
    173                                             <li> 
    174                                                 <cc2:FieldLabel ID="lblFirstName" runat="server" Text="First name" TargetID="FirstName"
    175                                                 </cc2:FieldLabel> 
    176                                                 <asp:TextBox ID="FirstName" runat="server"></asp:TextBox> 
    177                                             </li> 
    178                                             <li> 
    179                                                 <cc2:FieldLabel ID="lblLastName" runat="server" Text="Last name" TargetID="LastName"
    180                                                 </cc2:FieldLabel> 
    181                                                 <asp:TextBox ID="LastName" runat="server"></asp:TextBox> 
    182                                             </li> 
    183                                             <li> 
    184                                                 <cc2:FieldLabel ID="lblPosition" runat="server" Text="Position" TargetID="Position"
    185                                                 </cc2:FieldLabel> 
    186                                                 <asp:TextBox ID="Position" runat="server"></asp:TextBox> 
    187                                             </li>  
    188                                              <li> 
    189                                                 <cc2:FieldLabel ID="lblOffice" Visible="True" runat="server" Text="Office" TargetID="Office"
    190                                                 </cc2:FieldLabel> 
    191                                                 <asp:DropDownList ID="OfficeList" runat="server"  AutoPostBack ="True" OnLoad="LoadOffices"  OnSelectedIndexChanged="OfficeList_OnSelectedIndexChanged"  Height ="23px"></asp:DropDownList> 
    192                                                 <asp:TextBox ID="Office" runat="server" Visible="false"></asp:TextBox> 
    193                                             </li>    
    194                                             <li> 
    195                                                 <cc2:FieldLabel ID="lblOfficeName" runat="server" Text="OfficeName" TargetID="OfficeName" Visible="false"
    196                                                 </cc2:FieldLabel> 
    197                                                 <asp:TextBox ID="OfficeName" runat="server"  Visible="false" ></asp:TextBox> 
    198                                                  
    199                                             </li>  
    200                                                                                         
    201                                         </ol> 
    202                                     </fieldset> 
    203                                     <div class="bottom"
    204                                         <div> 
    205                                             <!-- --> 
    206                                         </div> 
    207                                     </div> 
    208                                     <div class="more"
    209                                         <cc1:DropDownPanel ID="MoreOptionsPanel" runat="server" Text="<%$Resources:MoreAboutTheUser %>"
    210                                             <h3>Contact</h3> 
    211                                             <fieldset class="userinfo set"
    212                                             <ol class="setIn"
    213                                                 <li> 
    214                                                     <cc2:FieldLabel ID="lblPhone" runat="server" Text="Phone" TargetID="Phone_Value"
    215                                                     </cc2:FieldLabel> 
    216                                                     <asp:TextBox ID="Phone_Value" runat="server"></asp:TextBox> 
    217  
    218                                                 </li> 
    219                                                 <li> 
    220                                                     <cc2:FieldLabel ID="lblIM_Value" runat="server" Text="Instant Messenger" TargetID="InstantMessenger_IM_Value"
    221                                                     </cc2:FieldLabel> 
    222                                                     <asp:TextBox ID="InstantMessenger_IM_Value" runat="server"></asp:TextBox> 
    223                                                 
    224                                                     <asp:DropDownList ID="InstantMessenger_IM_Type" runat="server"
    225                                                         <asp:ListItem Text="ICQ" Value="ICQ" Selected="True" /> 
    226                                                         <asp:ListItem Text="Skype" Value="Skype" /> 
    227                                                         <asp:ListItem Text="Google Talk" Value="Google Talk" /> 
    228                                                         <asp:ListItem Text="Windows Live (MSN)" Value="Windows Live (MSN)" /> 
    229                                                         <asp:ListItem Text="Yahoo! Messenger" Value="Yahoo! Messenger" /> 
    230                                                         <asp:ListItem Text="AIM" Value="AIM" /> 
    231                                                         <asp:ListItem Text="Jabber" Value="Jabber" /> 
    232                                                         <asp:ListItem Text="QQ" Value="QQ" /> 
    233                                                         <asp:ListItem Text="Other" Value="Other" /> 
    234                                                     </asp:DropDownList> 
    235                                                 </li> 
    236                                             </ol> 
    237                                             </fieldset> 
    238                                             <div class="bottom"
    239                                                 <div> 
    240                                                     <!-- --> 
    241                                                 </div> 
    242                                             </div> 
    243                                             <h3> Photo </h3> 
    244                                             <fieldset class="userinfo set"
    245                                                 <div class="setIn"
    246                                                     <asp:HiddenField ID="Photo_Hidden" runat="server" ></asp:HiddenField> 
    247                                                     <asp:Image ID="Photo" runat="server" ></asp:Image> 
    248                                                     <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%>" /> 
    249                                                 </div> 
    250                                             </fieldset> 
    251                                             <div class="bottom"
    252                                                 <div> 
    253                                                     <!-- --> 
    254                                                 </div> 
    255                                             </div> 
    256                                         </cc1:DropDownPanel> 
    257                                     </div> 
    258                                 </InsertTemplate> 
    259                                      
    260                             </cc1:ManageProfile> 
    261                             <h3>Roles</h3> 
    262                             <fieldset class="roles meta set"
    263                                 <div class="setIn clearfix check"
    264                                     <class="example"
    265                                         A role is a group of users associated with a set of user permissions.</p> 
    266                                     <cc2:CheckBoxOrderList runat="server" ID="RolesList"
    267                                     </cc2:CheckBoxOrderList> 
    268                                 </div> 
    269                             </fieldset> 
    270                             <div class="bottom"
    271                                 <div> 
    272                                     <!-- --> 
    273                                 </div> 
    274                             </div> 
    275                             <class="button_area"
    276                                 <asp:LinkButton ID="SaveUser" Text="Save" CommandName="Save" runat="server" CssClass="CmsButLeft okdark" 
    277                                     ValidationGroup="CreateUser"><strong class="CmsButRight dark">Create this user</strong></asp:LinkButton> 
    278                                 <span>or</span> 
    279                                 <asp:LinkButton ID="Button2" Text="Cancel" CommandName="Cancel" runat="server" CssClass="cmscclcmd" 
    280                                     CausesValidation="false">Cancel</asp:LinkButton> 
    281                             </p> 
    282                         </div> 
    283                         <div class="info" id="divFaq" runat="server"
    284                             <div class="infoBottom"
    285                                 <h3>Create Users FAQ</h3> 
    286                                 <dl class="faq"
    287                                     <dt>Can I change the username?</dt> 
    288                                     <dd> 
    289                                         No, once a username is set, it is final. The only way to change the username is 
    290                                         to register the user again and delete the old account.</dd> 
    291                                     <dt>What are roles?</dt> 
    292                                     <dd> 
    293                                         Roles define groups of users associated with the same permissions. They also determine 
    294                                         the parts of Sitefinity a user can view.</dd> 
    295                                     <dt>Can I assign a user to more than one role?</dt> 
    296                                     <dd> 
    297                                         Yes, you can assign a user to as many roles as you wish.</dd> 
    298                                     <dt>Can I move a user from one role to another later?</dt> 
    299                                     <dd> 
    300                                         Yes, you can do that any time. Just select and unselect the corresponding checkboxes.</dd> 
    301                                     <dt>Can I change this user's password later?</dt> 
    302                                     <dd> 
    303                                         No, you can't do that. The user can log in later to change his/her password.</dd> 
    304                                     <dt>Does the user receive an automatic e-mail with his/her credentials?</dt> 
    305                                     <dd> 
    306                                         Sorry, still N/A. You should inform them personally.</dd> 
    307                                 </dl> 
    308                                 <class="hideAllFAQs"
    309                                     <id="lnkHideFaq" href="javascript:void(0)" runat="server">Hide FAQs everywhere</a> 
    310                                 </p> 
    311                             </div> 
    312                         </div> 
    313                         <div class="clear width"
    314                         </div> 
    315                     </div> 
    316                 </InsertTemplate> 
    317                 <EditTemplate> 
    318                     <cc2:MessageControl runat="server" ID="message"
    319                         <ItemTemplate> 
    320                             <asp:Label runat="server" ID="messageText"></asp:Label> 
    321                         </ItemTemplate> 
    322                     </cc2:MessageControl> 
    323                     <div class="ToolsAll"
    324                         <div class="backWrapp"
    325                             <asp:LinkButton CommandName="Cancel" runat="server" ID="back" CssClass="actions back" 
    326                                 CausesValidation="false">Back to users</asp:LinkButton></div
    327                     </div> 
    328                     <div class="workArea"
    329                         <div class="mainForm"
    330                             <class="mand"
    331                                 * Mandatory fields</p> 
    332                             <h3> 
    333                                 Membership Info</h3> 
    334                             <fieldset class="userinfo set"
    335                                 <ol class="setIn"
    336                                     <li class="exField"
    337                                         <dl> 
    338                                             <dt>Username</dt><dd class="readOnly"><asp:Literal ID="UserName" runat="server"></asp:Literal></dd
    339                                             <dd class="example"
    340                                                 The username cannot be changed</dd> 
    341                                         </dl> 
    342                                     </li> 
    343                                     <li> 
    344                                         <cc2:FieldLabel ID="lblEmail" runat="server" Text="Email *" TargetID="Email"
    345                                         </cc2:FieldLabel> 
    346                                         <asp:TextBox ID="Email" runat="server"></asp:TextBox> 
    347                                         <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Email" 
    348                                             ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUser" 
    349                                             Display="Dynamic" CssClass="validMessage"><strong>E-mail cannot be empty!</strong></asp:RequiredFieldValidator> 
    350                                         <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="Email" 
    351                                             Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="\S+@\S+\.\S+" 
    352                                             ValidationGroup="CreateUser" CssClass="validMessage"><strong>The email format is invalid!</strong></asp:RegularExpressionValidator> 
    353                                     </li>                                     
    354                                     <li class="newPass"
    355                                         <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?');"/> 
    356                                     </li> 
    357                                 </ol> 
    358                             </fieldset> 
    359                             <div class="bottom"
    360                                 <div> 
    361                                     <!-- --> 
    362                                 </div> 
    363                             </div> 
    364                             <cc1:ManageProfile runat="server" ID="manageProfile" Mode="Edit"
    365                                 <EditTemplate> 
    366                                     <h3>User Details</h3> 
    367                                     <fieldset class="userinfo set"
    368                                         <ol class="setIn"
    369                                             <li> 
    370                                                 <cc2:FieldLabel ID="lblFirstName" runat="server" Text="First name" TargetID="FirstName"
    371                                                 </cc2:FieldLabel> 
    372                                                 <asp:TextBox ID="FirstName" runat="server"></asp:TextBox> 
    373                                             </li> 
    374                                             <li> 
    375                                                 <cc2:FieldLabel ID="lblLastName" runat="server" Text="Last name" TargetID="LastName"
    376                                                 </cc2:FieldLabel> 
    377                                                 <asp:TextBox ID="LastName" runat="server"></asp:TextBox> 
    378                                             </li> 
    379                                             <li> 
    380                                                 <cc2:FieldLabel ID="lblPosition" runat="server" Text="Position" TargetID="Position"
    381                                                 </cc2:FieldLabel> 
    382                                                 <asp:TextBox ID="Position" runat="server"></asp:TextBox> 
    383                                                 </li> 
    384                                              <li> 
    385                                                 <cc2:FieldLabel ID="lblOffice" Visible="True" runat="server" Text="Office" TargetID="Office"
    386                                                 </cc2:FieldLabel> 
    387                                                 <asp:DropDownList ID="OfficeList" runat="server"  AutoPostBack ="True" OnLoad="LoadOffices"  OnSelectedIndexChanged="OfficeList_OnSelectedIndexChanged"  Height ="23px"></asp:DropDownList> 
    388                                                 <asp:TextBox ID="Office" runat="server" Visible="false"></asp:TextBox> 
    389                                             </li>    
    390                                             <li> 
    391                                                 <cc2:FieldLabel ID="lblOfficeName" runat="server" Text="OfficeName" TargetID="OfficeName" Visible="false"
    392                                                 </cc2:FieldLabel> 
    393                                                 <asp:TextBox ID="OfficeName" runat="server"  Visible="false" ></asp:TextBox> 
    394                                                  
    395                                             </li>                                                  
    396                                             
    397                                         </ol> 
    398                                     </fieldset> 
    399                                     <div class="bottom"
    400                                         <div> 
    401                                             <!-- --> 
    402                                         </div> 
    403                                     </div> 
    404                                     <div class="more"
    405                                         <cc1:DropDownPanel ID="MoreOptionsPanel" runat="server" Text="<%$Resources:MoreAboutTheUser %>"
    406                                             <h3> Contact </h3> 
    407                                             <fieldset class="userinfo set"
    408                                                 <ol class="setIn"
    409                                                     <li> 
    410                                                         <cc2:FieldLabel ID="lblPhone" runat="server" Text="Phone" TargetID="Phone_Value"
    411                                                         </cc2:FieldLabel> 
    412                                                         <asp:TextBox ID="Phone_Value" runat="server"></asp:TextBox> 
    413  
    414                                                     </li> 
    415                                                     <li> 
    416                                                         <cc2:FieldLabel ID="lblIM_Value" runat="server" Text="Instant Messenger" TargetID="InstantMessenger_IM_Value"
    417                                                         </cc2:FieldLabel> 
    418                                                         <asp:TextBox ID="InstantMessenger_IM_Value" runat="server"></asp:TextBox> 
    419  
    420                                                         <asp:DropDownList ID="InstantMessenger_IM_Type" runat="server"
    421                                                             <asp:ListItem Text="ICQ" Value="ICQ" Selected="True" /> 
    422                                                             <asp:ListItem Text="Skype" Value="Skype" /> 
    423                                                             <asp:ListItem Text="Google Talk" Value="Google Talk" /> 
    424                                                             <asp:ListItem Text="Windows Live (MSN)" Value="Windows Live (MSN)" /> 
    425                                                             <asp:ListItem Text="Yahoo! Messenger" Value="Yahoo! Messenger" /> 
    426                                                             <asp:ListItem Text="AIM" Value="AIM" /> 
    427                                                             <asp:ListItem Text="Jabber" Value="Jabber" /> 
    428                                                             <asp:ListItem Text="QQ" Value="QQ" /> 
    429                                                             <asp:ListItem Text="Other" Value="Other" /> 
    430                                                         </asp:DropDownList> 
    431                                                     </li> 
    432                                                 </ol> 
    433                                             </fieldset> 
    434                                             <div class="bottom"
    435                                                 <div> 
    436                                                     <!-- --> 
    437                                                 </div> 
    438                                             </div> 
    439                                             <h3> Photo </h3> 
    440                                             <fieldset class="userinfo set"
    441                                                 <div class="setIn"
    442                                                     <asp:HiddenField ID="Photo_Hidden" runat="server" ></asp:HiddenField> 
    443                                                     <asp:Image ID="Photo" runat="server" ></asp:Image> 
    444                                                     <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%>" /> 
    445                                                 </div> 
    446                                             </fieldset>               
    447                                             <div class="bottom"
    448                                                 <div> 
    449                                                     <!-- --> 
    450                                                 </div> 
    451                                             </div> 
    452                                         </cc1:DropDownPanel> 
    453                                     </div> 
    454                                 </EditTemplate> 
    455                             </cc1:ManageProfile>     
    456                             <h3>Roles</h3> 
    457                             <fieldset class="roles meta set"
    458                                 <div class="setIn clearfix check"
    459                                     <class="example"
    460                                         A role is a group of users associated with a set of user permissions.</p> 
    461                                     <cc2:CheckBoxOrderList runat="server" ID="RolesList"
    462                                     </cc2:CheckBoxOrderList> 
    463                                 </div> 
    464                             </fieldset> 
    465                             <div class="bottom"
    466                                 <div> 
    467                                     <!-- --> 
    468                                 </div> 
    469                             </div> 
    470                             <class="button_area"
    471                                 <asp:LinkButton ID="Button1" Text="Save" CommandName="Save" runat="server" CssClass="CmsButLeft okdark" 
    472                                     ValidationGroup="CreateUser"><strong class="CmsButRight dark">Save user info</strong></asp:LinkButton> 
    473                                 <span>or</span> 
    474                                 <asp:LinkButton ID="Button2" Text="Cancel" CommandName="Cancel" runat="server" CssClass="cmscclcmd" 
    475                                     CausesValidation="false">Cancel</asp:LinkButton> 
    476                             </p> 
    477                         </div> 
    478                         <div class="info" id="divFaq" runat="server"
    479                             <div class="infoBottom"
    480                                 <h3>User Profile FAQ</h3> 
    481                                 <dl class="faq"
    482                                     <dt>Can I assign a user to more than one role?</dt> 
    483                                     <dd> 
    484                                         Yes, you can assign a user to as many roles as you wish.</dd> 
    485                                     <dt>Can I move a user from one role to another later?</dt> 
    486                                     <dd> 
    487                                         Yes, you can do that any time. Just select and unselect the corresponding checkboxes.</dd> 
    488  
    489                                 </dl> 
    490 <%--                                <class="hideAllFAQs"
    491                                     <id="lnkHideFaq" href="javascript:void(0)" runat="server">Hide FAQs everywhere</a> 
    492                                 </p>--%> 
    493                             </div> 
    494                         </div> 
    495                         <div class="clear"
    496                             <!-- --> 
    497                         </div> 
    498                     </div> 
    499                 </EditTemplate> 
    500                 <RolesTemplate> 
    501                     <cc2:MessageControl runat="server" ID="message"
    502                         <ItemTemplate> 
    503                             <asp:Label runat="server" ID="messageText"></asp:Label> 
    504                         </ItemTemplate> 
    505                     </cc2:MessageControl> 
    506                     <div class="workArea"
    507                         <div id="newRole"
    508                             <cc2:FieldLabel ID="lblNewRoleName" runat="server" Text="Create a role" TargetID="RoleName"
    509                             </cc2:FieldLabel> 
    510                             <asp:TextBox runat="server" ID="RoleName"></asp:TextBox> 
    511                             <asp:LinkButton ID="btnCreateRole" CommandName="CreateRole" runat="server" CssClass="CmsButLeft okdark"><strong class="CmsButRight dark">Create</strong></asp:LinkButton> 
    512                             <class="example"
    513                                 <strong>Example: </strong><q>Authors</q></p
    514                         </div> 
    515                         <div class="instruct"
    516                             <h3> 
    517                                 What is a role?</h3> 
    518                             <p> 
    519                                 A role is a group of users associated with a set of user permissions.</p> 
    520                         </div> 
    521                         <asp:GridView ID="GridView1" AutoGenerateColumns="false" GridLines="none" CssClass="listItems" 
    522                             runat="server"
    523                             <Columns> 
    524                                 <asp:BoundField DataField="Name" HeaderText="Role" HeaderStyle-CssClass="GridHeader_SiteFinity"
    525                                     <ItemStyle CssClass="gridContentTitle" /> 
    526                                 </asp:BoundField> 
    527                                 <asp:BoundField DataField="AssignedUsers" HeaderText="Assigned Users" HeaderStyle-CssClass="GridHeader_SiteFinity" /> 
    528                                 <asp:ButtonField ButtonType="Link" CommandName="Select" Text="View Users" AccessibleHeaderText="View Users"
    529                                     <ItemStyle CssClass="gridActions" Width="100px" /> 
    530                                 </asp:ButtonField> 
    531                                 <asp:ButtonField ButtonType="Link" CommandName="Delete" Text="Delete" AccessibleHeaderText="Delete"
    532                                     <ItemStyle CssClass="gridActions delete" /> 
    533                                 </asp:ButtonField> 
    534                             </Columns> 
    535                         </asp:GridView> 
    536                     </div> 
    537                 </RolesTemplate> 
    538             </cc1:ManageUsers> 
    539             <cc1:UsersCommands runat="server" ID="usersCommands"
    540                 <LayoutTemplate> 
    541                         <div class="clear"
    542                             <!-- --> 
    543                         </div> 
    544                      <h7><asp:Literal ID="Literal4" runat="server" Text="Users by username" /></h7
    545                     <cc1:AlphabetLinks runat="server" ID="alphabet" CssClass="alph-horizontal" /> 
    546                         <div class="clear"
    547                             <!-- --> 
    548                         </div> 
    549                     <asp:Literal ID="Literal1" runat="server" visible="false" Text="<%$ Resources:BrowseUsers %>" /> 
    550                     <div id="providersPanel" runat="server" class="provider SiteMapTools" > 
    551                         <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> 
    552                         <asp:DropDownList ID="ProvidersList" runat="server" AutoPostBack="true" /> 
    553                     </div>   
    554                     <strong id="all"
    555                         <asp:LinkButton runat="server" ID="cmdAllUsers" visible="false" CommandName="AllUsers" Text="<%$ Resources:AllUsers %>"></asp:LinkButton></strong
    556                      
    557                         <h7><asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:UsersByRole %>" /></h7
    558                         <ul class="RolesItemsList"
    559                         <asp:Repeater runat="server" ID="rolesRepeater"
    560                             <ItemTemplate> 
    561                                 <li> 
    562                                     <asp:LinkButton runat="server" ID="roleLink" CommandName="Select" CommandArgument='<%# Eval("Name")%>'><%# Eval("Name")%><span>(<%# Eval("AssignedUsers")%>)</span></asp:LinkButton></li
    563  
    564  
    565                             </ItemTemplate> 
    566                         </asp:Repeater> 
    567                     </ul> 
    568 <%--                    <div class="SiteMapTools" >--%> 
    569                         <class="coll" id="ddpCreateRole_lnk" href="javascript:togglePanel('ddpCreateRole')"
    570                             <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:CreateRole %>" Visible ="false" /></a><asp:LinkButton 
    571                                 runat="server" ID="cmdManageRoles" CommandName="ManageRoles" Text="<%$ Resources:ManageRoles %>" Visible ="false"></asp:LinkButton> 
    572                         <div class="ddlContent clearfix" id="ddpCreateRole_cnt" style="display: none;"
    573                             <cc2:FieldLabel ID="lblNewRoleName" runat="server" Text="Role name" TargetID="RoleName"
    574                             </cc2:FieldLabel> 
    575                             <asp:TextBox runat="server" ID="RoleName"></asp:TextBox> 
    576                             <asp:LinkButton ID="btnCreateRole" Text="Create" CommandName="CreateRole" runat="server" 
    577                                 CssClass="CmsButLeft okdark"><strong class="CmsButRight dark">Create</strong></asp:LinkButton> 
    578                             <div class="clear"
    579                                 <!-- --> 
    580                             </div> 
    581                         </div> 
    582 <%--                    </div>--%> 
    583  
    584                     <div> 
    585                          
    586                     </div>                    
    587                 </LayoutTemplate> 
    588             </cc1:UsersCommands> 
    589  
    590              <script type="text/javascript">             
    591             function togglePanel(id){ 
    592                 var el1 = document.getElementById(id + "_cnt"); 
    593                 var el3 = document.getElementById(id + "_lnk"); 
    594                 if (el1){ 
    595                     if (el1.style.display == "none"){ 
    596                         el1.style.display = "block"
    597                         el3.className = "ex"
    598                     } else { 
    599                         el1.style.display = "none"
    600                         el3.className = "coll"
    601                     } 
    602                 } 
    603             } 
    604             </script> 
    605         </div> 
    606     </div> 

    1 using System; 
    2 using System.Data; 
    3 using System.Configuration; 
    4 using System.Collections; 
    5 using System.Web; 
    6 using System.Web.Security; 
    7 using System.Web.UI; 
    8 using System.Web.UI.WebControls; 
    9 using System.Web.UI.WebControls.WebParts; 
    10 using System.Web.UI.HtmlControls; 
    11 using System.Data.SqlClient; 
    12  
    13 using Telerik.Cms; 
    14 using Telerik.Cms.Engine; 
    15 using Telerik.Cms.Security; 
    16 using Telerik.Cms.Web; 
    17 using Telerik.Cms.Web.UI; 
    18 using Telerik.Personalization; 
    19 using Telerik.Web.UI; 
    20 using Telerik.Security; 
    21 using Telerik.Security.WebControls; 
    22  
    23 public partial class UserControls_Custom_Controls_ManageUsers : System.Web.UI.UserControl 
    24
    25     public string MenuItemName 
    26     { 
    27         get { return "admin_users"; } 
    28     } 
    29  
    30     public int RightsRequired 
    31     { 
    32         get 
    33         { 
    34             return GlobalRights.ManageUsers; 
    35         } 
    36     } 
    37  
    38     protected override void OnInit(EventArgs e) 
    39     { 
    40         base.OnInit(e); 
    41         manageUsers.ModeChanged += new EventHandler(manageUsers_ModeChanged); 
    42         manageUsers.CreatedRole += new RoleCreatedEventHandler(manageUsers_CreatedRole); 
    43          
    44          
    45     } 
    46  
    47     void manageUsers_CreatedRole(object sender, GlobalPermissionsEventArgs e) 
    48     { 
    49         if (UserManager.Default.RoleProvider.Name == e.RoleProviderName) 
    50         { 
    51             GlobalPermissions.Instance.SetPermissions(e.GlobalPermissions, 0, UserManager.Default.RoleProvider.Name, new string[] { e.Role }); 
    52         } 
    53     } 
    54  
    55  
    56     protected void Page_Load(object sender, EventArgs e) 
    57     { 
    58         manageUsers.AttachCommandPanel(usersCommands); 
    59  
    60             //this.msgControl.Message = thedd.SelectedValue.ToString (); 
    61             //this.msgControl.Mode = MessageMode.Success; 
    62  
    63             HtmlControl div = this.usersCommands.Container.FindControl("providersPanel"as HtmlControl; 
    64             if (div != null
    65                 div.Visible = false
    66  
    67          
    68  
    69         if (!Page.IsPostBack) 
    70         { 
    71             if (Request.QueryString.Get("mode") != null 
    72                 && Request.QueryString.Get("mode").Equals("new")) 
    73             { 
    74                  
    75                 manageUsers.Mode = ManageUsers.Modes.Insert; 
    76  
    77             } 
    78  
    79             if (UserManager.GetCurrentRoleProviderName().ToString() != "Sitefinity"
    80             { 
    81                 manageUsers.ProviderName = "customProvider"
    82                 // if(Roles.RoleExists("Office:" + Profile.OfficeName)) 
    83                 manageUsers.FindUsersByRole("Office:" + Profile.OfficeName); 
    84  
    85             } 
    86  
    87             if (Request.QueryString.Get("action") != null && 
    88                 Request.QueryString.Get("action").Equals("profile") && 
    89                 Request.QueryString.Get("username") != null
    90             {  // access to profile from Newsletter groups (CMS users) 
    91                 string username = Request.QueryString.Get("username"); 
    92                 manageUsers.UserName = username; 
    93             } 
    94         } 
    95  
    96          
    97  
    98         if (Page.IsPostBack) 
    99         { 
    100             //string ctrlname = this.Page.Request.Params.Get("__EVENTTARGET"); 
    101  
    102             if (this.Page.Request.Params.Get("__EVENTTARGET").Contains("MyRoles")) 
    103             { 
    104                 if (UserManager.GetCurrentRoleProviderName().ToString() != "Sitefinity"
    105                 { 
    106                     //manageUsers.ProviderName = "customProvider"; 
    107                     // if(Roles.RoleExists("Office:" + Profile.OfficeName)) 
    108                     manageUsers.FindUsersByRole("Office:" + Profile.OfficeName); 
    109  
    110                 } 
    111  
    112             } 
    113         } 
    114  
    115  
    116     } 
    117     void manageUsers_ModeChanged(object sender, EventArgs e) 
    118     { 
    119         switch (manageUsers.Mode) 
    120         { 
    121             case ManageUsers.Modes.List: 
    122                 //this.ControlPanelTitle.InnerText = (string)GetLocalResourceObject("Users"); 
    123                 break
    124             case ManageUsers.Modes.Insert: 
    125                 { 
    126                     //this.ControlPanelTitle.InnerText = String.Format("{0} > {1}", (string)GetLocalResourceObject("Users"), (string)GetLocalResourceObject("CreateNew")); 
    127                    // SetFaqVisibility(); 
    128                     break
    129                 } 
    130             case ManageUsers.Modes.Edit: 
    131                 { 
    132                    // this.ControlPanelTitle.InnerText = String.Format("{0} > {1}", (string)GetLocalResourceObject("Users"), (string)GetLocalResourceObject("Edit")); 
    133                    // SetFaqVisibility(); 
    134                     break
    135                 } 
    136             case ManageUsers.Modes.Roles: 
    137                 //this.ControlPanelTitle.InnerText = (string)GetLocalResourceObject("Roles"); 
    138                 break
    139         } 
    140     } 
    141     public void OfficeList_OnSelectedIndexChanged(object sender, EventArgs e) 
    142     { 
    143  
    144         ListItem li; 
    145         //li.Selected = true; 
    146         //Response.Write (dd.SelectedValue .ToString () +  "  li:" + li.Value .ToString ()); 
    147         TextBox office; 
    148         DropDownList dd = new DropDownList(); 
    149         dd = ((DropDownList)sender); 
    150         li = dd.SelectedItem; 
    151  
    152         dd.ClearSelection(); 
    153         dd.SelectedValue = li.Value; 
    154         TextBox officeID = ((TextBox)dd.Parent.FindControl("Office")); 
    155         office = ((TextBox)dd.Parent.FindControl("OfficeName")); 
    156         office.Text = dd.SelectedItem.Text; 
    157         officeID.Text = li.Value; 
    158         //Response.Write (" on index change "); 
    159  
    160  
    161     } 
    162  
    163  
    164     public void LoadOffices(object sender, EventArgs e) 
    165     { 
    166  
    167  
    168         string[] value; 
    169         value = Roles.GetAllRoles(); 
    170         DropDownList dd = new DropDownList(); 
    171         dd = ((DropDownList)sender); 
    172         TextBox office; 
    173         if (dd.Items.Count == 0) 
    174         { 
    175  
    176             //DropDownList dd = new DropDownList(); 
    177             //dd = ((DropDownList)sender); 
    178             office = ((TextBox)dd.Parent.FindControl("OfficeName")); 
    179  
    180  
    181             //DropDownList officeDD; 
    182             SqlConnection con; 
    183             SqlCommand cmdSelect; 
    184             SqlDataReader sqlReader; 
    185             String query; 
    186             //    officeDD = new DropDownList(); 
    187  
    188  
    189             con = new SqlConnection(ConfigurationManager.ConnectionStrings["CCRREARSConnectionString"].ConnectionString); 
    190  
    191  
    192  
    193  
    194             for (int i = 1; i < value.Length; i++) 
    195             { 
    196  
    197                 if (value[i].Contains("Office:")) 
    198                 { 
    199  
    200                     try 
    201                     { 
    202                         con.Open(); 
    203                         SqlParameter param = new SqlParameter("CCRR", SqlDbType.VarChar); 
    204                         param.Value = value[i].Substring(7); 
    205                         cmdSelect = new SqlCommand("Select Id,CCRR from ccrr_names Where CCRR = @CCRR", con); 
    206                         cmdSelect.Parameters.Add(param); 
    207                         sqlReader = cmdSelect.ExecuteReader(); 
    208                         sqlReader.Read(); 
    209                         if (sqlReader.HasRows) 
    210                         { 
    211                             ListItem li = new ListItem(); 
    212                             li.Text = sqlReader.GetValue(1).ToString(); 
    213                             li.Value = sqlReader.GetValue(0).ToString(); 
    214                             if (office.Text.ToString() == li.Text.ToString()) 
    215                             { 
    216                                 li.Selected = true
    217  
    218                             } 
    219                             dd.Items.Add(li); 
    220                         } 
    221                         sqlReader.Close(); 
    222                     } 
    223                     catch (Exception e2) 
    224                     { 
    225  
    226                         Response.Write(e2.Message); 
    227                     } 
    228  
    229                     con.Close(); 
    230                 } 
    231  
    232             } 
    233  
    234         } 
    235  
    236     } 
    237     protected void passwordRecoveryButton_Click(object sender, EventArgs e) 
    238     { 
    239         string newPassword = manageUsers.Manager.MembershipProvider.ResetPassword(manageUsers.UserName, "42"); 
    240         Telerik.Security.WebControls.ManageUsers.EditContainer editContainer = manageUsers.GetCurrentContainer() as Telerik.Security.WebControls.ManageUsers.EditContainer; 
    241         if (editContainer != null
    242         { 
    243             Control passRecovery = editContainer.FindControl("passwordRecoveryButton"); 
    244             if (passRecovery != null
    245             { 
    246                 int index = editContainer.Controls.IndexOf(passRecovery); 
    247  
    248                 Literal newPass = new Literal(); 
    249                 newPass.Text = "New password: "
    250  
    251                 Label newNote = new Label(); 
    252                 newNote.Controls.Add(newPass); 
    253                 Literal passLiteral = new Literal(); 
    254                 passLiteral.Text = newPassword; 
    255                 HtmlGenericControl strong = new HtmlGenericControl("strong"); 
    256                 strong.Controls.Add(passLiteral); 
    257  
    258                 newNote.Controls.Add(strong); 
    259  
    260                 editContainer.Controls.AddAt(index + 1, newNote); 
    261             } 
    262         } 
    263     } 
    264  
    265     private void SetFaqVisibility() 
    266     { 
    267         Control container = manageUsers.GetCurrentContainer(); 
    268  
    269         if (container == nullreturn
    270  
    271         HtmlGenericControl divFaq = container.FindControl("divFaq"as HtmlGenericControl; 
    272  
    273         if (divFaq != null
    274         { 
    275             divFaq.Visible = Telerik.Personalization.PersonalizationManager.DefaultInstance.GetGlobalValue<bool>(Telerik.Personalization.GlobalSettingConstants.ShowFaq, true); 
    276  
    277             if (divFaq.Visible) 
    278             { 
    279                 HtmlAnchor lnkHideFaq = container.FindControl("lnkHideFaq"as HtmlAnchor; 
    280  
    281                 if (lnkHideFaq != null
    282                 { 
    283                     string script = string.Format(System.Globalization.CultureInfo.CurrentCulture, "javascript:Personalization.hideFaqSection('{0}')", divFaq.ClientID); 
    284  
    285                     lnkHideFaq.Attributes.Add("onclick", script); 
    286                 } 
    287             } 
    288         } 
    289     } 
    290
    291  

  15. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    06 Aug 2009
    Link to this post
    Answered my own question ...sort of.

    When I was trying to edit the profile of a user from the grid I was always choosing my self the currently logged in users.  I have not figured out the reason yet but apparently you can not edit your own profile this way, while you are logged in.

    I am successful in editing other members profile, just as long as I'm not editing the profile of the member I'm logged in as.

     
  16. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Aug 2009
    Link to this post
    Hello Aaron,

    Thank you for the additional information.

    You are not able to persist the updates made to profile of the member you are logged in with (default administrator probably) because he does not belong to your custom membership provider. The default administrator account that you create when starting a new project is stored in the Sitefinity membership provider. Basically you are only able to edit user profiles from your custom membership provider (since you select it in code).

    I hope adds in to your own answer to the question.

    Kind regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  17. Aaron
    Aaron avatar
    39 posts
    Registered:
    16 Apr 2009
    11 Aug 2009
    Link to this post
    That makes perfect sense, however I was logged in as a user from my custom provider.  Although this user is allowed to have sitefinity cms access based on the permissions I have set.