Remove tool dynamically from RadEditor

4 posts, 0 answers
  1. William
    William avatar
    22 posts
    Member since:
    May 2011

    Posted 14 Feb 2012 Link to this post

    Hi Guys,

    Could someone tell me how to remove a tool from the RadEditor dynamically. When someone logs into my page, I want to be able to turn a tool off. Any help would be greatly appreciated.

    William
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 15 Feb 2012 Link to this post

    Hello William,

     Here is an article with sample code on how to achieve what you need:

    http://www.telerik.com/help/aspnet-ajax/editor-removing-toolbar-buttons.html

    Please, test the suggested solution and let us know how it goes.

    Greetings,
    Svetlina Anati
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. William
    William avatar
    22 posts
    Member since:
    May 2011

    Posted 21 Feb 2012 Link to this post

    I'm using VB and I tried this and it didn't work. I couldn't get "RemoveButton()" to be recognized by VB. Is there a specific IMPORT that I need to be using to get this to work.
  4. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 22 Feb 2012 Link to this post

    William:

    You are correct that the VB.NET code that is provided on the Removing Toolbar Buttons documentation page does not work as provided.

    I have modified it and I am providing the working version.

    Default.aspx.vb:
    Imports Telerik.Web.UI
     
    Partial Class _Default
        Inherits System.Web.UI.Page
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                RadEditor1.EnsureToolsFileLoaded()
                RemoveButton("FindAndReplace")
                RemoveButton("Cut")
                RemoveButton("Copy")
                RemoveButton("Paste")
            End If
        End Sub
     
        Public Sub RemoveButton(ByVal name As String)
            For Each group As Telerik.Web.UI.EditorToolGroup In RadEditor1.Tools
                Dim tool As EditorTool = group.FindTool(name)
                If Not tool Is Nothing Then
                    group.Tools.Remove(tool)
                End If
            Next
        End Sub
    End Class

    This removes the four buttons from the RadEditor's basic toolbar on the Page_Load event.

    Hope this helps!
Back to Top