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

Forums / Developing with Sitefinity / HideToolboxControls in page edit mode based on role

HideToolboxControls in page edit mode based on role

9 posts, 0 answered
  1. sam
    sam avatar
    3 posts
    Registered:
    10 Apr 2007
    06 Apr 2008
    Link to this post
    Hi,

    Can someone give me an example of how to programmatically hide the Add Controls option in page edit mode based on role.

    My requirements mean I can't use workflow or other work arounds..
  2. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    09 Apr 2008
    Link to this post
    Anyone know the answer to this?
  3. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    10 Apr 2008
    Link to this post
    Hello sam,

    We apologize for the delayed response.

    Normally the answer to this question would be no, Add Controls item cannot be managed by the Administrative default role settings.

    Best wishes,
    Nikifor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    10 Apr 2008
    Link to this post
    that would be incorrect because I got the following from a support answer:

    We apologize for the delayed response.

    It would be possible to hide the Add Control toolbox by applying custom implementation which will override the  method used now. Please extract the archived files in the attachment, and copy the HideToolbox.cs in the ~/YourWebSite/App_Code folder. Mind that on the line 15 you should put the name of the your role instead of "Sitefinity". The last step is to replace the existing EditPage.aspx file in the ~/YourWebSite/Sitefinity/Admin folder with the provided one (see attachment).

    Please let me know if you need any further assistance.

    using System;
    using System.Web;
    using Telerik.Cms.Web.UI;
    using Telerik.Cms.Web;
    using System.Web.UI;
    using System.Web.Security;

    public class HideToolbox : EditPage
    {
        protected override void OnPreRender(EventArgs e)
        {
            RolePrincipal currentUser = HttpContext.Current.User as RolePrincipal;

            // check if the user is in the pageViewers role, you could add custom logic here
            if (currentUser.IsInRole("Sitefinity"))
            {
                ToolBar toolBar = this.Form.FindControl("toolBar") as ToolBar;
                Toolbox toolBox = null;
                if (toolBar != null)
                {
                    // find the toolbox control, this could be an expensive operation
                    foreach (Control control in toolBar.Controls)
                    {
                        toolBox = control as Toolbox;
                        if (toolBox != null)
                            break;
                    }
                }

                if (toolBox != null)
                {
                    // hide toolBox control
                    toolBox.Expanded = false;
                    toolBox.Enabled = false;
                }
            }

            base.OnPreRender(e);
        }
    }

    Editpage.aspx

    %@ Page Inherits="HideToolbox" MasterPageFile="~/Sitefinity/Dummy.master" %>

    Obviously support calls go to developers with stronger knowledge of the product.
    You would think support call answers would be put into the knowledge base or something..
  5. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    11 Apr 2008
    Link to this post
    Hi Sam,

    I apologize for the inconvenience. As you can see both emails were answered by me. The difference is that the first one got sent accidentally before adding the information on the solution, and I missed to send the rest of the answer. Please accept my sincere apologies for any inconvenience caused. Your Telerik account has been updated.

    The given resolution in the forum thread, provided to Dai Bevan, would definitely apply in your particular case since I created the User Control for you.

    Sincerely yours,
    Nikifor Hristov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    12 Apr 2008
    Link to this post
    I am sorry, that was my bad.

    I am very impressed with the help we are receiving from you guys and appreciate it very much.

    I have one more question.

    I am wanting to create a user control that displays products in a repeat from a datasource. We are wanting to keep the description of each product in the cms workflow.

    I need to dynamically create a rad text editor or generic control for each product and then have the abilty to edit  these in edit mode. And then use the page workflow to hold the description info.

    How could I approach this problem?

    Thanks
  7. Jason M
    Jason M avatar
    108 posts
    Registered:
    15 Jan 2007
    16 Apr 2008
    Link to this post
    Can someone please attach the code?  We'd like to implement this with our site.

    Thanks!
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    17 Apr 2008
    Link to this post
    Hello,

    Sam,
    The easiest way to achieve this task is to build your own module based on the Generic Content module, because Workflow is implemented for the Generic Content. This way, your module will inherit this implementation.

    We haven't tried to build custom module (not based on Generic Content) with workflow so far - that is why we are not able to provide you with sample code. We'll try to improve our Developer Manual on this topic. In case you want to try, you should reference the Telerik.Framework assembly.

    The last suggestion is to build a regular pluggable module and implement your own Workflow logic.

    Jason,
    I'm not quite sure which code you want us to attach. If it is related to the Workflow-enabled module, as we described you would have to create it yourself following the above directions. If it is related to hiding the Add Controls option, based on roles, please see the attached file. Let us know if this is not the case.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Jason M
    Jason M avatar
    108 posts
    Registered:
    15 Jan 2007
    17 Apr 2008
    Link to this post
    Thanks Georgi!  I was looking for the hide Add Control code.
Register for webinar
9 posts, 0 answered