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

Server side override of buttons

5 Answers 157 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 08 Sep 2011, 01:36 PM
Hello,

I would like to know whether there is a way to dynamically create an ImageEditor and override, for example, the Save functionality in such a way that I don't need any client-side script and the functionality is handled server-side. Thanks in advance,

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 08 Sep 2011, 07:03 PM
Hi Mike,

RadImageEditor offers ImageSaving server-side event that is fired when the Save button is clicked. You can handle this event to apply modifications to the saving functionality.

The following code snippet demonstrate handling of the ImageSaving event and create a thumbnail image:
protected void RadImageEditor1_ImageSaving(object sender, ImageEditorSavingEventArgs args)
{
    var thumbImage = args.Image.Clone();
    thumbImage.Resize(90, 90);
 
    var ms = new MemoryStream();
    thumbImage.Image.Save(ms, thumbImage.RawFormat);
    File.WriteAllBytes(String.Format("{0}{1}.{2}", MapPath(pathToThumbs), args.FileName, thumbImage.Format), (byte[])ms.ToArray());
}

Greetings,
Dobromir
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Mike
Top achievements
Rank 1
answered on 09 Sep 2011, 07:29 AM
Hello Dobromir,

Firstly, thank you for your swift response. Furthermore, I might have not been clear enough as what I am trying to achieve : I wish to override the onclick event from a(ny) button on the toolbar (in this case the "Save Image" button) in server-side code, thus cancelling the popup and handling the process associated with the button server-side, without using client-side code. The event you are describing happens after clicking the Save button on the popup window (the window I do not wish to show). Thanks in advance, Mike
0
Niko
Telerik team
answered on 12 Sep 2011, 04:30 PM
Hi Mike,

Unfortunately not all operations are done directly on the server-side, thus it is not possible to capture  the commands by canceling the default execution.
You have two options to go when you wish to change the executing command. Still both of them are on the client-side.
One option is to attach to the OnClientCommandExecuting. You could cancel the default execution through args.set_cancel(true) and incorporate your own implementation:
function customCommand(imageEditor,args)
{
    args.set_cancel(true);
    //do custom command actions
}
Another options is to directly override the command or create your own. You should either redefine an existing command in the CommandList or define your own:
Telerik.Web.UI.ImageEditor.CommandList.CustomCommand = function(imageEditor, commandName, args)
{
    //do custom command actions
}
In order to associate a button to a custom command you can create a new tool in the Tools collection and assign the CommandName property with the corresponding command name.

Hope this helps.

Best wishes,
Niko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 13 Sep 2011, 08:05 AM
Hello Niko,

Thank you for your answer. However, since there is no way of overriding methods server-side, the RadImageEditor control is clearly not the control suited to my needs and I have to keep looking for another component. This is too bad, because up until now, I have always been impressed with the flexibility of the controls from the Telerik library.
Kind regards, Mike
0
IT
Top achievements
Rank 1
answered on 22 Sep 2012, 06:48 PM
I needed to do the same thing

Save the file to the server and also the database along with some additional database values.

I was able to do this using a combination of the RsyncUpload  / RadImageEditor

If you still require help with this then let me know and i'll publish some sample code

Tags
ImageEditor
Asked by
Mike
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Mike
Top achievements
Rank 1
Niko
Telerik team
IT
Top achievements
Rank 1
Share this question
or