MOSSRadEditor Custom Button programmatically

3 posts, 0 answers
  1. thomas
    thomas avatar
    8 posts
    Member since:
    Mar 2009

    Posted 19 Mar 2009 Link to this post

    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();
    EditorTool CustomTool = new EditorTool();
    CustomTool.Name = "TestButton";
    CustomTool.Enabled = true;
    CustomTool.ShowText = true;

    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 ...

  2. thomas
    thomas avatar
    8 posts
    Member since:
    Mar 2009

    Posted 19 Mar 2009 Link to this post

    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";
    EditorTool CustomTool = new EditorTool();
    CustomTool.Text = "TEST";
    CustomTool.Enabled= true;
    CustomTool.ShowIcon = false;

    it shows my Custom Button :-)
  3. Stanimir
    Stanimir avatar
    1654 posts

    Posted 20 Mar 2009 Link to this post

    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.

    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.
Back to Top