Load image from code behind and export image to custom location

4 posts, 1 answers
  1. Archana
    Archana avatar
    7 posts
    Member since:
    Nov 2015

    Posted 01 Jun 2018 Link to this post

    Hi,

    How do I set the path of ImageUrl in ImageEditor from code behind? radImageEditor.ImageUrl="<file path>" did not load the image.

    Also, how do I export the image to a custom file path?

  2. Answer
    Vessy
    Admin
    Vessy avatar
    2068 posts

    Posted 01 Jun 2018 Link to this post

    Hi Archana,

    RadImageEditor can work only with virtual paths to images placed inside the application root directory, so setting its ImageUrl from the code-behind should look like follows:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadImageEditor1.ImageUrl = "~/Images/image1.jpg";
    }

    As for the saving the image to a custom location, you can do it in the control's ImageSaving event like demonstrated in this live demo:
    https://demos.telerik.com/aspnet-ajax/imageeditor/examples/customsaving/defaultcs.aspx
    protected void RadImgEdt_ImageSaving(object sender, Telerik.Web.UI.ImageEditorSavingEventArgs args)
     {
         //Save the image to a custom location
         string fullPath = Server.MapPath("../../images/testImages");
         string fileName = string.Format("relax-{0}.jpg", DateTime.Now.ToString("yyyyMMdd-hhmmss"));
         fullPath = Path.Combine(fullPath, fileName);
     
         Telerik.Web.UI.ImageEditor.EditableImage img = args.Image;
         img.Image.Save(fullPath);
         //lblError.Text = "File Saved";
         args.Argument = String.Format("The image is saved under the name: <strong>{0}</strong>.", fileName);
     
         args.Cancel = true;
     }


    Regards,
    Vessy
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Archana
    Archana avatar
    7 posts
    Member since:
    Nov 2015

    Posted 04 Jun 2018 in reply to Vessy Link to this post

    Thanks Vessy.. that helped.
  4. Vessy
    Admin
    Vessy avatar
    2068 posts

    Posted 04 Jun 2018 Link to this post

    Hi,

    You are welcome, Archana. Let us know should you meed any further difficulties with our controls.

    Regards,
    Vessy
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top