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

disable hyperlink toolbar button on RadEditor html and preview mode

3 Answers 261 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Sakshi
Top achievements
Rank 1
Sakshi asked on 08 Jul 2012, 04:27 PM
Hi Everyone,

I have a RadEditor with couple of toolbar buttons which includes hyperlink manager toolbar button.

I have edit modes as design, html and preview.

I would like to disable hyperlink when on html and preview modes, and disable on design mode until a button is clicked.

i tried if mode = design, visible = false, but it does not work all the time.

Example:
1st time when I load the module, by default it is in design mode, and hyperlink is disabled, when i switch to html/preview modes, the hyperlink is disabled,but when i switch back again to design ,the hyperlink is enabled.

"Any Idea how to disable hyperlink in all the 3 modes and enable only on design mode when a button is clicked."

Thanks in advance for you help on this.

-Rad

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Jul 2012, 07:53 AM
Hi Rad,

Try the following Javascript to achieve your scenario.

JS:
<script type="text/javascript">
 function pageLoad()
 {
   var editor = $find("<%=RadEditor.ClientID %>");
   editor.get_toolContainer().control.getToolByName("LinkManager").set_visible(false);
 }
 function OnClientModeChange(editor, args)
  {
   editor.get_toolContainer().control.getToolByName("LinkManager").set_visible(false);
  }
 function OnClientClick()
  {
   var editor = $find("<%=RadEditor.ClientID %>");
   editor.get_toolContainer().control.getToolByName("LinkManager").set_visible(true);
   return false;
  }
</script>

Hope this helps.

Thanks,
Princy.
0
Bob
Top achievements
Rank 1
answered on 11 Jul 2012, 02:28 PM
Hello,

I have a similar request.  I have a tool (FindAndReplace) that is visible only in HTML mode and wanted to write something to disable it (in HTML mode).  I tried implementing the code from you previous post with alterations.  Below is the block that I am working with...

Thanks,

Bob

<telerik:RadEditor ID="txtStory" runat="server" Width="99%" Height="670" AllowScripts="True" 
TabIndex="3" ToolbarMode="Default" DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd"
OnClientLoad="OnClientLoad" EnableEmbeddedSkins="false" Skin="PrestoRadSkin" 
NewLineMode="P" ContentFilters="ConvertToXhtml" OnClientModeChange="OnClientModeChange"
ExternalDialogsPath="~/DesktopModules/ContentDashboard/Telerik/Dialogs/"
StripFormattingOptions="MSWordRemoveAll"
ToolsFile="~/DesktopModules/ContentDashboard/Telerik/ToolsFile.xml" >
<CssFiles>
<telerik:EditorCssFile Value="~/DesktopModules/ContentDashboard/RadEditorStyles.css" />
</CssFiles>
<Tools>
<telerik:EditorToolGroup Tag="MainToolbar">
<telerik:EditorTool Name="Cut" />
<telerik:EditorTool Name="Copy" ShortCut="CTRL+C" />
<telerik:EditorTool Name="Paste" ShortCut="CTRL+V" />
<telerik:EditorTool Name="pullQuote" Text="Pull Quote" />
<telerik:EditorTool Name="blockQuote" Text="Block Quote" />
<telerik:EditorTool Name="createSpike" Text="Insert a new Spike" />
<telerik:EditorTool Name="createMap" Text="Insert a new Map" />
<telerik:EditorTool Name="stripBlockFormat" Text="Remove all formatting from the selected paragraph." />
           <telerik:EditorTool Name="pageBreak" Text="Insert Blog Page Break" />
</telerik:EditorToolGroup>
<telerik:EditorToolGroup Tag="Other Bar">
<telerik:EditorTool Name="Bold" ShortCut="CTRL+B" />
<telerik:EditorTool Name="Italic" ShortCut="CTRL+I" />
<telerik:EditorTool Name="Underline" ShortCut="CTRL+U" />
<telerik:EditorTool Name="InsertOrderedList" />
<telerik:EditorTool Name="InsertUnorderedList" />
</telerik:EditorToolGroup>
<telerik:EditorToolGroup Tag="EditToolbar">
<telerik:EditorTool Name="FindAndReplace" ShortCut="CTRL+F" />
<telerik:EditorTool Name="SelectAll" ShortCut="CTRL+A" />
<telerik:EditorSplitButton Name="Undo" />
<telerik:EditorSplitButton Name="Redo" />
<telerik:EditorSplitButton Name="InsertSymbol" />
</telerik:EditorToolGroup>
<telerik:EditorToolGroup Tag="SubToolbar">
<telerik:EditorTool Name="PasteHtml" ShortCut="CTRL+H" Text="Embed HTML" />
<telerik:EditorTool Name="ImageUpload" ShortCut="CTRL+M" Text="Image Upload" />
<telerik:EditorTool Name="LinkManager" ShortCut="CTRL+K" />
<telerik:EditorTool Name="Unlink" ShortCut="CTRL+SHIFT+K" />
</telerik:EditorToolGroup>
</Tools>
</telerik:RadEditor>
0
Vessy
Telerik team
answered on 13 Jul 2012, 01:29 PM
Hi Rad,

In order to set the button state in HTML mode, you have to attach to the OnClientModeChange event to the editor. I am providing you with a sample code which you could apply in your scenario :

<script type="text/javascript">
    function OnClientModeChange(editor, args){
        if (editor.get_mode() == 2) {
            setTimeout(function () {
                editor.getToolByName("FindAndReplace").setState(-1);
            }, 0);
        }
    }
</script>
<telerik:RadEditor runat="server" ID="RadEditor1" OnClientModeChange="OnClientModeChange">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="FindAndReplace" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>

I hope that would be helpful for you.

All the best,
Veselina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Sakshi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or