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

Problem with loss of file references in RadAsynceUpload

4 Answers 31 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 14 Oct 2014, 06:37 PM
I've only recently replaced the RadUpload controls in my web app with RadAsyncUploads.  By and large they're working OK.

In the postback event I grab a reference to the uploaded file ( UploadedFile file = RadUpload1.UploadedFiles[0]; ) and process it.

There's one small problem.  The page the upload control is on also has several custom validators that do server-side validation.  If one of these validators fires the file reference in the RadAsyncUpload control is wiped and it is necessary to select the file again. 

Am I forgetting something basic?  

4 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 16 Oct 2014, 03:09 PM
Hello,

I assume that a button will initiate a post-back to the server in order to validate the user input. The RadAsyncUpload PostbackTriggers property contains the control ids that will fire the RadAsyncUpload FileUploaded server-side event and move the file from the temp folder to the target folder.

So basically if you have a RadButton set as a post-back trigger for the RadAsyncUpload and hide it the other button will not submit the files but will make a post-back in order to execute your custom validation.
//markup code
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" PostbackTriggers="RadButton1"></telerik:RadAsyncUpload>
            <telerik:RadButton AutoPostBack="true" runat="server" ID="RadButton1" Visible="false"></telerik:RadButton>
            <telerik:RadButton AutoPostBack="true" runat="server" ID="RadButton2"></telerik:RadButton>



Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Boris
Top achievements
Rank 1
answered on 16 Oct 2014, 04:51 PM
I'm afraid I'm still lost.  If I set up the controls like you suggest, the AsyncUpload control seems to retain it's setting (file name is still visible) but after I correct the server-side validation and hit the save button again, the UploadedFiles property is still empty.
0
Boris
Top achievements
Rank 1
answered on 16 Oct 2014, 07:40 PM
Let me elaborate a bit more.  If the Save button is clicked and the save routine is run, the uploaded file is handled like this:

  if (RadUpload1.UploadedFiles.Count > 0)              
  {
       UploadedFile file = RadUpload1.UploadedFiles[0];                    
       byte[] bytes = new byte[file.ContentLength];
       file.InputStream.Read(bytes, 0, (int)file.ContentLength);
       ...  At this point the file is inserted into a record field, and then the record itself is saved,  etc.


Am I going about this all wrong?
0
Boris
Top achievements
Rank 1
answered on 20 Oct 2014, 02:11 PM
Let's close this.  I found an alternative.
Tags
AsyncUpload
Asked by
Boris
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Boris
Top achievements
Rank 1
Share this question
or