'--------------------
' Note: custom buttons with all their properties can be created within aspx.
' That would reduce size of hidden viewstate field and improve persistance of properties.
' To generate toolbar items at visual design,- the editor for Toolbar property can be used.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Me.IsPostBack) Then
Return
End If
'-------------------
' Add another item to a build-in Insert drop-down list
Dim dropDownInsert As ToolbarDropDown = CType(Me.WebHtmlEditor1.FindByKeyOrAction("Insert"), ToolbarDropDown)
If (Not dropDownInsert Is Nothing) Then
dropDownInsert.Items.Add(New ToolbarDropDownItem("Signature2", "<span style='background-color:red'>My Signature<span>"))
End If
'-------------------
' Add another item to the Style (font-style) drop-down list.
' Note: commented line below shows example to remove default items from list.
' Me.WebHtmlEditor1.FontStyleList.Clear()
Dim dropDownFont As ToolbarDropDown = CType(Me.WebHtmlEditor1.FindByKeyOrAction("FontStyle"), ToolbarDropDown)
If (Not dropDownFont Is Nothing) Then
dropDownFont.Items.Add(New ToolbarDropDownItem("40px", "font-size:40px"))
End If
'-------------------
' Add a custom button with custom action.
' Note: implementation of actual action requires processing ClientSideEvents.BeforeAction
Dim customAction As ToolbarButton = New ToolbarButton()
customAction.Key = "MyCustomAct"
customAction.Type = ToolbarButtonType.Custom
Me.WebHtmlEditor1.Toolbar.Items.Add(customAction)
End Sub
To process custom actions on client, application should set
<ClientSideEvents BeforeAction="WebHtmlEditor1_BeforeAction" />
and codes below should appear within the HEAD section of HTML.
<script type="text/javascript">
<!--
// function fired before actions
function WebHtmlEditor1_BeforeAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8)
{
// if it is our custom MyCustomAct toolbar button,
// then insert text at the current selection in editor
if(actID == "MyCustomAct")
{
iged_insText("My Custom Action");
}
}
// -->
</script>