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

Q1 2009 -> Q2 2009 breaking change

2 Answers 45 Views
Upload
This is a migrated thread and some comments may be shown as answers.
sherwin
Top achievements
Rank 1
sherwin asked on 16 Jul 2009, 09:38 AM
Hi,

A change in the RadUpload component between Q1 and Q2 release has broken some functionality in my application:

My app handles the RadUpload.UploadCanceled event, where I check if *any* of the files were uploaded succesfully before the user clicked cancel:

 private void RadUpload1_UploadCanceled(object sender, EventArgs e) 
   if (RadUpload1.CurrentSession.UploadedFiles.Count > 0) 
   { 
     //some files *did* upload succesfully, so do something... 
   }         

This code works just fine in Q1, but in Q2, CurrentSession.UploadedFiles.Count is *always' zero regardless of how many files were uploaded prior to clicking 'cancel'.

I have compared the Q1 and Q2 RadUpload components using Reflector, and have found a change in Q2 that resets the RadUpload session *before* raising the UploadCanceled event:

Q1 code:
public void CancelUpload() 
    if (this.CurrentSession.uploaders.Count > 0) 
    { 
        this.CurrentSession.uploaders.Peek().Cancel(); 
    } 
    this.SetInitialUIState(); 
 

Q2 code:
public void CancelUpload() 
    if (this.CurrentSession.Uploaders.Count > 0) 
    { 
        this.CurrentSession.Uploaders.Peek().Cancel(); 
    } 
    this.CurrentSession.Reset(); 
    this.SetInitialUIState(); 
 
  
 
  
 

Note the new call to this.CurrentSession.Reset(), this is whats causing me problems! I can work around this by manually tracking how many files have successfully been uploaded, but this smells like a bug to me. Or perhaps you need to add an 'UploadCanceling' event, to be raised prior to 'UploadCanceled', where the session info would still be intact.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan
Telerik team
answered on 16 Jul 2009, 01:27 PM
Hello Sherwin,

Thank you for reporting the issue.

We would like to apologize for the inconvenience. Yes we are confirming that the upload cancelation clears the CurrentSession. The fix was scheduled - we hope it will be available for the upcoming SP1 release. Meanwhile you can workaround using UploadStarted, FileUploaded and UploadCanceled events:
 
private void RadUpload1_UploadStarted(object sender, FileUploadedEventArgs e) 
    this.uploaded = 0; 
 
private void RadUpload1_FileUploaded(object sender, FileUploadedEventArgs e) 
    if (e.HandlerData.IsSuccess) 
    { 
        this.uploaded++; 
    } 
 
private void RadUpload1_UploadCanceled(object sender, FileUploadedEventArgs e) 
    if (this.uploaded > 0) 
    { 
        // ... your code here 
    } 

Your Telerik points are updated according to reporting the issue.

All the best,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sherwin
Top achievements
Rank 1
answered on 16 Jul 2009, 01:33 PM
thank for confirming it, your fix is exactly what i did to work around this issue :-)
Tags
Upload
Asked by
sherwin
Top achievements
Rank 1
Answers by
Ivan
Telerik team
sherwin
Top achievements
Rank 1
Share this question
or