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

Clear Image

11 Answers 283 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
DogBizPro
Top achievements
Rank 1
DogBizPro asked on 03 Aug 2015, 07:02 PM
How do you clear the image from the Image Edit? For example, I have the ImageEdit on a RadWindow to allow uploading/cropping an image. If I click 'select' choose an image and click 'upload' and then close the rad window that image is still there. How do I make that a 'new' ImageEditor when the button is clicked again to open the RadWindow?

11 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 06 Aug 2015, 12:59 PM
Hi Stephanie,

In order to reload the content of RadWindow every time it is shown you have to configure its ReloadOnShow and ShowContentDuringLoad properties like follows:
<telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="ImageEditor.aspx" Width="900" Height="700" ReloadOnShow="true" ShowContentDuringLoad="false"></telerik:RadWindow>

I hope this helps.

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
DogBizPro
Top achievements
Rank 1
answered on 06 Aug 2015, 04:21 PM

Thanks but the issue is I am loading the RadWindow as follows:

 imbDog.Attributes.Add("onclick", "openRadWindow('" + Constants.DIALOG_DOGPHOTO + "?pic=y&dog=" + d.ID.ToString() + "'); return false;");                        

Even if I go to a totally different page and click to open this particular rad window for a another client in our system that same photo is loaded into the ImageEditor. It has to be caching it or something. That seems to be the real issue. How do I clear the ImageEditor cach?

0
Accepted
Vessy
Telerik team
answered on 11 Aug 2015, 11:31 AM
Hi Stephanie,

The ImageEditor does not have its own logic for keeping the loaded images in the cache (unless its ImageStorageLocations=Cache property is not configured). If you are uploading the images following the approach from this live demo, though, the uploaded image will be added to the application cache for 20 minutes:
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
    //Clear changes and remove uploaded image from Cache
    RadImageEditor1.ResetChanges();
    Context.Cache.Remove(Session.SessionID + "UploadedFile");
    using (Stream stream = e.File.InputStream)
    {
        byte[] imgData = new byte[stream.Length];
        stream.Read(imgData, 0, imgData.Length);
        MemoryStream ms = new MemoryStream();
        ms.Write(imgData, 0, imgData.Length);
 
        Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero);
    }
}

Please note that this is only a sample approach used for our demo application purposes and I would suggest that you review the following MSDN resources in order to consider how to integrate it best in the target by you scenario:
Cache.Insert Method
Cache.Remove Method​
Cache Methods

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
DogBizPro
Top achievements
Rank 1
answered on 12 Aug 2015, 03:50 PM
Thanks for the reply. I am not using any of that code to cache it, but each time I click on the upload icon that opens the RadWindow with the RadImageEditor on it the last image displays automatically. I just want to know how to eliminate that so it loads empty like it does the first time.
0
DogBizPro
Top achievements
Rank 1
answered on 12 Aug 2015, 03:54 PM
I found that it was loading from the cache as part of the example I copied. I got it now. Thanks!
0
DogBizPro
Top achievements
Rank 1
answered on 12 Aug 2015, 04:05 PM

Okay, I lied. I removed that code and the original upload didn't work....

 

    protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args)
    {
        //Handle Uploaded images
        if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null))
        {
            using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile")))
            {
                args.Image = image.Clone();
                args.Cancel = true;
            }
        }
    }

How do I get the upload to work without reloading the picture on susequent calls to the window?​

0
Vessy
Telerik team
answered on 17 Aug 2015, 02:28 PM
Hi Stephanie,

That is expected, as the image uploading logic implemented by us in the demo is based on caching the uploading image and loading it from the cache after that. In order to customize this logic to cache the image for less than 20 minutes you will need to decrease the fourth parameter of the Cache.Insert() method and make sure that you clear the cache each time when the window holding the ImageEditor is closed. Examining the articles provided in my previous reply should be helpful for you in implementing the desired custom scenario.

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
DogBizPro
Top achievements
Rank 1
answered on 17 Aug 2015, 06:56 PM
Great. I think that fixes things. Is there a way to display a 'Image Saved....' message when clicking on the Save icon in the toolbar or close the RadWindow?
0
Vessy
Telerik team
answered on 18 Aug 2015, 02:48 PM
Hi Stephanie,

You can attach a handler to the ImageEditor's client-side ClientSaved event which is raised just after the image is saved, and populate a label from its handler. A similar approach is used in the following demo:
ImageEditor - Save Image to a Custom Location

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
DogBizPro
Top achievements
Rank 1
answered on 18 Aug 2015, 05:44 PM
Thanks for the reply. I tried doing that and I am not getting the message to populate. Also, I when I click save on the toolbar it is saving in the same location as the file for the RadWindow in addition to the correct location that I am saving it in the web application. How to I eliminate it from saving in the directory with the RadWindow code?
0
Vessy
Telerik team
answered on 21 Aug 2015, 10:39 AM
Hi Stephanie,

In order to avoid the saving of the image in its default location, you have to cancel the arguments of the ImageSaving event:
protected void RadImgEdt_ImageSaving(object sender, Telerik.Web.UI.ImageEditorSavingEventArgs args)
{
    ...
    args.Cancel = true;
}

As for you other question, I have just answer your other thread on the subject and will advice that will continue the discussion about it there.

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ImageEditor
Asked by
DogBizPro
Top achievements
Rank 1
Answers by
Vessy
Telerik team
DogBizPro
Top achievements
Rank 1
Share this question
or