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

How can I have a custom toolbar button execute server-side code?

1 Answer 60 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ross Presser
Top achievements
Rank 1
Ross Presser asked on 18 Jun 2014, 10:36 PM
When the user clicks this button on the toolbar, I want to trigger some server side code which will convert from "HTML scripting" to "VB scripting" in our system.  (Neither of those things is exactly what you think it is. ) I have created the toolbar button:
    Private Sub formatFieldScriptingHtml(ByRef re As RadEditor, ByVal textdir As eDocLibrary.eDocFieldInfo.textDirection)
 
        re.ToolsFile = "~/include/FieldScriptingToolsFile.xml"
        're.DisableFilter(EditorFilters.IndentHTMLContent)
        re.ContentFilters = EditorFilters.None
 
        'This button needs to be added in codebehind, because it gets localized button text
        'The other buttons are standard toolbar buttons that get localized by Telerik
        Dim toVB = New Telerik.Web.UI.EditorTool
        toVB.Name = "toVB"
        toVB.Text = Resources.Main.ConvertToVbButtonText '"Convert to VB", localized
        toVB.ShowIcon = False
        toVB.ShowText = True
        re.Tools(0).Tools.Add(toVB)
' ... omitted code
End Sub

And I've put this in a RadScriptBlock, though I'm not sure it's working:
<telerik:RadScriptBlock>
    <script>
        Telerik.Web.UI.Editor.CommandList["toVB"] = function (commandName, editor, args) {
            var ajaxManager = $find("<%= AjaxManager.ClientID%>");
            ajaxManager.ajaxRequest("toVB");
        }
    </script>
</telerik:RadScriptBlock>

Will this look for a server side function called "toVB"? Or what exactly do I have to do?

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 19 Jun 2014, 01:44 PM
Hello Ross,

Using the RadAjaxManager to invoke a code behind logic should be further implemented by attaching a server-side OnAjaxRequest event handler and handle the passed arguments in the implemented VB method.

You can find a proper example in this help article by following Example 1 and 2.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Editor
Asked by
Ross Presser
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or