This is a migrated thread and some comments may be shown as answers.

Remove tool dynamically from RadEditor

3 Answers 227 Views
Editor
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 14 Feb 2012, 06:56 PM
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

3 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 15 Feb 2012, 01:48 PM
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 >>
0
William
Top achievements
Rank 1
answered on 21 Feb 2012, 02:49 PM
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.
0
Richard
Top achievements
Rank 1
answered on 22 Feb 2012, 06:36 PM
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!
Tags
Editor
Asked by
William
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
William
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or