Wednesday, June 10, 2009

How to add a Custom Button on TopToolBar of HTML Editor

As to the new AjaxControlToolkit control HTML Editor, if some one wants to add a custom button onto TopToolBar of Editor and do some custom code, you can add a MethodButton and define client-side onclick to do script. It's no way to define server-side onclick of it. However, you can build a doPostBack functionality on client if you'd like to do onclick on the server-side.

public class CustomEditor : AjaxControlToolkit.HTMLEditor.Editor
public CustomEditor()
// TODO: Add constructor logic here

protected override void FillTopToolbar()

AjaxControlToolkit.HTMLEditor.ToolbarButton.MethodButton btn=new AjaxControlToolkit.HTMLEditor.ToolbarButton.MethodButton();
btn.NormalSrc= "aa.jpg";
btn.Attributes.Add("onclick", "alert('a');");



This new feature has been added to Editor control. You can download it and create custom button in editor control:


ZHANG said...

Hi, thank you so much for this article. I wanna creat a custom button to insert a string of html into the content, I know in Obout HtmlEditor, it has a client side api “InsertHtml()”, could you please tell how to realize this with ajax html editor ?

Anonymous said...

See how to add "correctly" custom buttons here:

Vince Xu said...

Thanks for that new feature.

Anonymous said...

Thank you so much for this article.


Your movies on demand

Custom Paper Writing said...

Many institutions limit access to their online information. Making this information available will be an asset to all.

Gabriel McAdams said...
This comment has been removed by the author.
Gabriel McAdams said...

I just added a tip to my blog showing how to set the default state of the editor's toolbar buttons.

SocialLiberal said...

I put this code into my project, but it doesn't appear to do anything.

Perhaps you can elaborate on how we're supposed to use this code?

crookedalley said...

Really i impressed. What a wonderful presentation.Now i am happy.Thank You