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

MOSSRadEditor Custom Button programmatically

2 Answers 57 Views
WebParts for SharePoint
This is a migrated thread and some comments may be shown as answers.
thomas
Top achievements
Rank 1
thomas asked on 19 Mar 2009, 09:19 AM
Hello all,

I'm trying to add a custom button to my MOSSRadEditor, but it doesn't show when rendering my Control.

This is my Code:

MOSSRadEditor re_editor = new MOSSRadEditor();
EditorToolGroup main = new EditorToolGroup();
re_editor.Tools.Add(main);
EditorTool CustomTool = new EditorTool();
CustomTool.Name = "TestButton";
CustomTool.Enabled = true;
CustomTool.ShowText = true;
main.Tools.Add(CustomTool);

Are there extra properties to configure? And where do I handle the event for that button, can i add the javascript for that button programmatically in the control.
Or something like this.page.ClientScript. ...

Thx!

2 Answers, 1 is accepted

Sort by
0
thomas
Top achievements
Rank 1
answered on 19 Mar 2009, 10:03 AM
Hm, this is weird. On my webcontrol OnLoad event the the tools from the editor has 6 groups with each ... tools.
When I override the pre_render then it only has one group (mosstools)
So now:

void editor_PreRender(object sender, EventArgs e) {
EditorToolGroup main = new EditorToolGroup();
main.Tag = "main";
editor.Tools.Add(main);
EditorTool CustomTool = new EditorTool();
CustomTool.Name="TEST";
CustomTool.Text = "TEST";
CustomTool.Enabled= true;
CustomTool.ShowIcon = false;
main.Tools.Add(CustomTool);
base.OnPreRender(e);
}

it shows my Custom Button :-)
0
Stanimir
Telerik team
answered on 20 Mar 2009, 07:47 AM
Hi Thomas,

The reason for this behavior is that the OnLoad event is too early to set your custom button. At the end of the OnLoad event the tools file of the Editor is loaded and it overwrites the changes that you has made. So when you define your custom button in the pre_render event, the tools file is already loaded and you can overwrite the settings set by it. In the ASP.NET AJAX version of RadEditor there is an EnsureToolsFileLoaded method which you can call if you want to be sure that the tools file will not overwrite your settings. Unfortunately this method is not featured in old ASP.NET version of the editor. So if you want to add a custom button, you need to do it after the OnLoad event is finished.


Greetings,
Stanimir
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.
Tags
WebParts for SharePoint
Asked by
thomas
Top achievements
Rank 1
Answers by
thomas
Top achievements
Rank 1
Stanimir
Telerik team
Share this question
or