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

How to set the tool button's attribute on C# code? like the "onclick".

2 Answers 32 Views
Editor
This is a migrated thread and some comments may be shown as answers.
alloovee
Top achievements
Rank 1
alloovee asked on 22 Nov 2010, 05:07 AM
hi,
In the past, we can set the tool button's attribute like this:
WebControl btn= this.Editor1.ToolControls["InsertImage"].Control as WebControl;
btn.Attributes["onclick"] = "alert('hellow telerik');";

But now it seem that we cannot make it like that ! 
this is the client-side way:
<script type="text/javascript">  
var imageManagerCommand = RadEditorCommandList["ImageManager"];  
RadEditorCommandList["ImageManager"] = function(commandName, editor, oTool)   
{   
    imageManagerCommand (commandName, editor, callBackFn);   
      
    function callBackFn(result)   
    {   
        if (result && result.imagePath)   
        {   
           
 
           
        };   
    }   
}  
</script> 

WebControl ctrl = this.Editor1.ToolControls["InsertImage"].Control as WebControl;
            ctrl.Attributes["onclick"] = "alert('damnd');";
WebControl ctrl = this.Editor1.ToolControls["InsertImage"].Control as WebControl;
            ctrl.Attributes["onclick"] = "alert('damnd');";
WebControl ctrl = this.Editor1.ToolControls["InsertImage"].Control as WebControl;
            ctrl.Attributes["onclick"] = "alert('damnd');";
WebControl ctrl = this.Editor1.ToolControls["InsertImage"].Control as WebControl;
            ctrl.Attributes["onclick"] = "alert('damnd');";
 WebControl ctrl = this.Editor1.ToolControls["InsertImage"].Control as WebControl;
            ctrl.Attributes["onclick"] = "alert('damnd');"
Is there a way to do it in C# code?

Thanks for your reply!

Regards

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 24 Nov 2010, 04:04 PM
Hi,

The new RadEditor uses a different toolbar architecture and the requested functionality is not supported out-of-the box.

What you can do is:
1) To append a server Asp:Button to the toolbar, which will allow you to use its server onclick event. You can see how to embed a server control in the toolbar in this forum thread: Can I add a combobox to radeditor's tools collection
2) or use the following solution:

Add a custom toolbar button and a hidden asp:button on the page with RadEditor. In the RadEditorCommandList function of the custom button, get a reference to the hidden asp button and click it using $find("<%=Button1.ClientID%>").click();. In the click event handler of the asp button execute the desired server code.


Greetings,
Rumen
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
alloovee
Top achievements
Rank 1
answered on 25 Nov 2010, 02:14 AM
Thanks for your answer!

with your point, setting in the javascript page is conciser。

Thanks again,I'll do it!
Tags
Editor
Asked by
alloovee
Top achievements
Rank 1
Answers by
Rumen
Telerik team
alloovee
Top achievements
Rank 1
Share this question
or