Server side override of buttons

6 posts, 0 answers
  1. Mike
    Mike avatar
    3 posts
    Member since:
    Sep 2011

    Posted 08 Sep 2011 Link to this post

    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,
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 08 Sep 2011 Link to this post

    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 >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    3 posts
    Member since:
    Sep 2011

    Posted 09 Sep 2011 Link to this post

    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
  5. Niko
    Admin
    Niko avatar
    387 posts

    Posted 12 Sep 2011 Link to this post

    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.
  6. Mike
    Mike avatar
    3 posts
    Member since:
    Sep 2011

    Posted 13 Sep 2011 Link to this post

    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
  7. IT
    IT avatar
    26 posts
    Member since:
    Dec 2008

    Posted 22 Sep 2012 Link to this post

    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

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