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

2 posts, 0 answers
  1. Ross Presser
    Ross Presser avatar
    30 posts
    Member since:
    Dec 2008

    Posted 18 Jun 2014 Link to this post

    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?
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 19 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top