Clear Image

12 posts, 1 answers
  1. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 03 Aug 2015 Link to this post

    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?
  2. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 06 Aug 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 06 Aug 2015 in reply to Vessy Link to this post

    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?

  5. Answer
    Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 11 Aug 2015 Link to this post

    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
  6. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 12 Aug 2015 in reply to Vessy Link to this post

    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.
  7. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 12 Aug 2015 in reply to Stephanie Link to this post

    I found that it was loading from the cache as part of the example I copied. I got it now. Thanks!
  8. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 12 Aug 2015 in reply to Stephanie Link to this post

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

  9. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 17 Aug 2015 Link to this post

    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
  10. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 17 Aug 2015 in reply to Vessy Link to this post

    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?
  11. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 18 Aug 2015 Link to this post

    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
  12. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 18 Aug 2015 in reply to Vessy Link to this post

    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?
  13. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 21 Aug 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017