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

Server Side Save + Custom Processing

1 Answer 71 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Yurko
Top achievements
Rank 1
Yurko asked on 14 Jan 2020, 06:40 PM

Im trying to SAVE the resulting image to the server. Tried following some sample code with no luck

Sever side code never fires

(Code simple passes a MEMORY STREAM object to  a function (doc.AddVersion) that will save the content into the database)

 

Error: Sys.ArgumentException: Cannot deserialize empty string.
Parameter name: data ScriptResource.axd:50457:2736
    create
    argument
    deserialize
    _readJson
    _finishOperation
    createCallback
    createDelegate
    WebForm_ExecuteCallback
    WebForm_CallbackComplete
 
Protected Sub RadImgEdt_ImageSaving(sender As Object, args As Telerik.Web.UI.ImageEditorSavingEventArgs)
       Dim doc As Object = tableDocumentGeneric.getDocument()
       Dim img As Telerik.Web.UI.ImageEditor.EditableImage = args.Image
       Dim ms As New IO.MemoryStream
       img.CopyToStream(ms)
       doc.AddVersion(ms)
       args.Cancel = True
   End Sub

 

<telerik:RadImageEditor ID="RadImageEditor1" runat="server"
    OnClientImageLoad="OnClientImageLoad"
    OnClientCommandExecuting="OnClientCommandExecuting"
    OnImageSaving="RadImgEdt_ImageSaving"
    Style="top: 0px; left: 0px;" Width="100%" Height="100%">
    <EditableImageSettings MaxJsonLength="2147483640" />
    <Tools>
        <telerik:ImageEditorToolGroup>
            <telerik:ImageEditorTool CommandName="Print"/>
            <telerik:ImageEditorTool CommandName="Save" />
            <telerik:ImageEditorTool CommandName="Crop" />
            <telerik:ImageEditorTool CommandName="Zoom" />
            <telerik:ImageEditorToolStrip Text="Undo" CommandName="Undo" />
            <telerik:ImageEditorToolStrip Text="Redo" CommandName="Redo" />
            <telerik:ImageEditorTool Text="Rotate Right" CommandName="RotateRight" />
            <telerik:ImageEditorTool Text="Rotate Left" CommandName="RotateLeft" />
            <telerik:ImageEditorTool Text="Reset" CommandName="Reset" />
        </telerik:ImageEditorToolGroup>
    </Tools>
</telerik:RadImageEditor>
 
<script>
    (function (global, undefined) {
        Telerik.Web.UI.ImageEditor.CommandList["Print"] = function (imgEditor, commandName, args) {
            printIT();
        };
    })(window);
    function printIT() {

        //redirect to show PDF version of item

    }
 
    function OnClientImageLoad(imageEditor, args) {
        imgEditor = imageEditor;
        imgEditor.set_height(document.body.scrollHeight - 50);
        imageEditor.zoomBestFit();
    }
 
    //SAVE
    function OnClientCommandExecuting(imageEditor, eventArgs) {
        if (eventArgs.get_commandName() == 'Save') {
            console.log(eventArgs);
            imageEditor.saveImageOnServer('', true);
            //Prevent the buil-in Save dialog to pop up
            imageEditor.setToggleState('Save', false);
            imageEditor.saveImageOnServer('', true);
            eventArgs.set_cancel(true);
 
        }
    }
 
</script>

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 15 Jan 2020, 01:12 PM

Hi Yurko,

I tested the provided setup and the ImageSaving event was fired successfully at my end. Can you confirm that there are no JavaScript error thrown on the page when Save button is clicked?

For convenience, I am attaching my test page to this reply so you can test it at your end, I am using the latest version of the controls.

Regards,
Vessy
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
ImageEditor
Asked by
Yurko
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or