SaveEditableImage

8 posts, 0 answers
  1. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 27 Sep 2011 Link to this post

    On the server-side, I would like to save any changes made in the ImageEditor.  How can this be done?  I've messed with SaveEditableImage but am unable to get it to save correctly.  I have a button on the page:

    <div class="BadgePopup">
        <telerik:RadUpload runat="server" ID="_upload" FocusOnLoad="True"
            MaxFileInputsCount="1" ControlObjectsVisibility="None" Skin="Forest"
            TargetFolder="~/BadgePhotos" Width="240px"></telerik:RadUpload>
        <telerik:RadButton runat="server" ID="_submit" Text="Upload" onclick="_submit_Click" Skin="Forest"></telerik:RadButton>     
        <telerik:RadButton ID="_finished" runat="server" Text="Save" onclick="_photo_Finished" Skin="Forest" /><br /><br />
     
        <telerik:RadImageEditor ID="_image" runat="server" Skin="Forest" Width="400px" Height="213px"
            AllowedSavingLocation="Server" ToolsFile="~/BadgePhotos/Dialogs.xml" >
        </telerik:RadImageEditor>
    </div>

    And then the codebehind:
    protected void _photo_Finished(object sender, EventArgs e)
    {
        using (DAL.KeeleyBarcodeDataContext dal = new DAL.KeeleyBarcodeDataContext())
        {
            DAL.Employee emp = (from n in dal.Employees where n.EmployeeID == new Guid(EmployeeID) select n).First();
            emp.PicturePath = Path.GetFileName(_image.ImageUrl);
     
            _image.SaveEditableImage(emp.PicturePath, true);
            dal.SaveChanges();
        }
    }

    If I do a simple resize of the image and click "Save" (my save, not the save on the toolbar), the SaveEditableImage code runs without an exception, yet the image is not saved with the new resized dimensions.  I am implementing this Save method because my users don't like to click on the Save on the toolbar and then yet another Save so I can update the DB.









  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 30 Sep 2011 Link to this post

    Hello Eric,

    The SaveEditableImage method expects only the file name to be passed, and not the entire path. So if you want to save the image in a custom location you should handle and cancel the ImageSaving server-side event, and then save it in the desired location.
    Calling the SaveEditableImage method will trigger the ImageSaving server-side event.

    Best wishes,
    Pero
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Manh Gioi
    Manh Gioi avatar
    2 posts
    Member since:
    Oct 2011

    Posted 24 Oct 2011 Link to this post

    I still can not save images in other folders. Please help me with an example.. Please !
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 26 Oct 2011 Link to this post

    Hello Manh,

    Here is the requested example:

    Default.aspx:
    <telerik:RadImageEditor ID="RadImageEditor1" runat="server"
        ImageUrl="~/Images/Vucko.jpg" onimagesaving="RadImageEditor1_ImageSaving">
    </telerik:RadImageEditor>

    Default.aspx.cs

    protected void RadImageEditor1_ImageSaving(object sender, ImageEditorSavingEventArgs args)
    {
        args.Image.Image.Save(MapPath("~/Images/SubFolder/Vucko.jpg"));
        args.Cancel = true;
    }

    The Vucko.jpg image resides in the Images folder placed in the root of the project. After saving the image through the Save dialog of RadImageEditor, the edited image will be saved in the SubFolder folder placed inside the root Images folder.

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Manh Gioi
    Manh Gioi avatar
    2 posts
    Member since:
    Oct 2011

    Posted 31 Oct 2011 Link to this post

    Thanks Rumen  !

    How to change the percentage value of crop photos "AspectRatio" and assign a default value for the image "Width and Height"in the "Crop image" of radimageeditor?

  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 31 Oct 2011 Link to this post

    Hello Manh,

    You can see how to customize the Crop dialog in the following forum threads:
    http://www.telerik.com/community/forums/aspnet-ajax/image-editor/crop-dialog-using-static-width-height.aspx
    and
    http://www.telerik.com/community/forums/aspnet-ajax/image-editor/no-save-on-server-aspect-ration-and-more.aspx

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  8. Azadeh
    Azadeh avatar
    11 posts
    Member since:
    Mar 2012

    Posted 20 Jun 2012 Link to this post

    Hi Roman,
    can i insert a button in my form that in OnClick Event call a Method for save image to another location?
  9. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 25 Jun 2012 Link to this post

    Hi Azadeh,

    RadImageEditor does not offer the required functionality out-of-the-box. However, you can achieve the required result using a additional element to pass the destination folder's path to the server and use it in the ImageSaving server-side event.

    For your convenience I have attached sample page demonstrating this approach using RadComboBox to select destination folder.


    Kind regards,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017