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

Recommendation for the following use case

6 Answers 108 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Yoram
Top achievements
Rank 1
Yoram asked on 20 Jun 2012, 01:56 PM
I would like to get your suggestion to handle the following use case:
  1. The form is based on the ASP:Wizard for ordering map prints
  2. The user selects maps from a database, the selected maps are added to a cart stored as datatable in the session variables. The selected maps are shown in a RadGrid with the requested quantities.
  3. In the next wizard step: For those maps with more than certain copies, the user can upload overlay information to be printed on the maps. For each line in the RadGrid shown in this step an AsyncUpload control is displayed.
  4. Only after the user completes all of the required information such as delivery and payment the cart will be stored as a record in the database.

My questions:
  1. What will be the best practice to handle the files being upload until the cart is suppose to be stored in the database?
  2. How to avoid multiple uploads for the same item? Should I worry about it?
  3. How can I clear files when the purchase was not completed? 

Thanks,
Yoram

6 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 25 Jun 2012, 09:07 AM
Hi Yoram,

I will answer you in the order you asked your question.

1. After a postback a FileUploaded event is fired for every file. You can handle the event and manipulate the file as you want.

2. MaxFileInputsCount property get/set the number of the uploaded files. In case that you want the user to upload only one file you can set the property to 1.

3. Yes, you can. When a file is uploaded a remove button is rendered next to the file name. With jQuery you can click on the remove button and remove the file. E.g. :
if (some condition) {
   $(".ruRemove").click();
}

In case that you are facing some difficulties to implement your case, please setup a working sample project and send it for a local investigation.

All the best,
Peter Filipov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Yoram
Top achievements
Rank 1
answered on 23 Jul 2012, 01:56 PM
Hi Peter,

I do not feel you've address my problems.
I'm aware of the FileUpload event. However, my question is as follow:
  • The user choosed a file for upload (each control at each row has max of 1)
  • The user click the next step of the wizard
  • The event FileUpload was fired, How should I store the file in the interim period until the cart is completed? Shell I let it stay in the Temporary Upload folder?
  • If the user click on the back button of the wizard and gets back to the previous grid, it showes an empty FileUpload control with no indication that he already selected a file to upload for his cart. If he selects to upload again, now I have multiple files in the Temporary folder. The later should have overwritten the privious one. From the customer expirance perspective, he thinks that the file he previous uploaded is not there anymore if he gets an empty FileUpload control.

  1. Assuming I'm handling the first event fired by the FileUploaded, If I choose to save the file in the target folder and the cart has been aborted I need a way to remove it?
  2. If the user click on the back button and returns to the grid with the UploadControl, how can I programticaly on the server side set in the FileUpload the file that was previously selected?

Thanks,
Yoram
0
Accepted
Bozhidar
Telerik team
answered on 25 Jul 2012, 09:34 AM
Hello Yoram,

Thank you for getting back to us.

For the specified scenario I would suggest a different approach. Instead of using an asp:Wizard control, you can use RadTabStrip and RadMultiPage. These controls can be set up to work and look like a wizard, but they also offer the ability to save the state of the controls placed inside of them, when set up properly.

To demonstrate how you can achieve the desired functionality I've attached a small sample page with a very simple RadMultiPage control set up as a Wizard. On the first page you have a RadAsyncUpload control and a button "Next". The second page contains only 2 buttons - "Prev" and "Finish". When you select a file in the upload control and move to the next page, the file is not yet uploaded. You can event go back to the previous page and remove the selected file and add another one. This is achieved by the PostBackTriggers property of RadAsyncUpload. You can learn more about this feature in the following demo:
http://demos.telerik.com/aspnet-ajax/upload/examples/async/persistuploadedfiles/defaultcs.aspx?product=asyncupload 

When you click the Finish button, the file is uploaded and displayed in a RadBinaryImage.

You can see a more detailed demo of RadTabStrip and RadMultiPage working as a Wizard in the following demo:
http://demos.telerik.com/aspnet-ajax/tabstrip/examples/applicationscenarios/wizard/defaultcs.aspx 

Hope this is helpful.
 
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Yoram
Top achievements
Rank 1
answered on 27 Aug 2012, 09:02 AM
Hi Bozhidar,

I've tried your suggestion, I'm still facing a problem.
My AsyncUpload is part of grid itemtemplate:
<telerik:GridTemplateColumn UniqueName="Upload" HeaderText="Upload File">
    <ItemTemplate>
        <telerik:RadAsyncUpload ID="AsyncUpload1" runat="server" AllowedFileExtensions="zip,ocd"
MaxFileInputsCount="1" MaxFileSize="524288" PostbackTriggers="rbNext2Delivery"
TargetFolder="~/app_Data/Uploads" OnFileUploaded="AsyncUpload1_FileUploaded">
        </telerik:RadAsyncUpload>
      </ItemTemplate>
</telerik:GridTemplateColumn>

The grid is dynamicaly bind to datatable which is stored as session variable (since this is the cart information)
Protected Sub RadGrid2_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) _ 
Handles RadGrid2.NeedDataSource
objDT = Session("MapCart")
RadGrid2.DataSource = objDT
End Sub

After I select the file to be uploaded and the AsyncUpload GUI shows it completes its loading phase, I move to the next RadPage. When I go back to the previous RadPage with the above grid. The AsyncUpload shows as empty, I would like the user to have an indication he already selected a file to be uploaded and it is pending the completing of the purchase process, or even the option to remove the file and select a different one.

I would prefer to add the file information to the Cart Session Table and maybe to use it to fill the AsyncUpload when the user goes to the previous step.

Any suggestions?

BR,
Yoram
0
Bozhidar
Telerik team
answered on 29 Aug 2012, 03:12 PM
Hi Yoram,

I tested the case where the AsyncUpload is nested inside the ItemTemplate of RadGrid, but it is working fine on my end. The issue must be related to your specific implementation. Could you modify the code from the example I sent you (keeping it as simple as possible) so that it resembles your implementation and reproduces the issue and paste it here, so that I can use it to test the issue locally.
 
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Yoram
Top achievements
Rank 1
answered on 30 Aug 2012, 05:44 AM
Hi Again,

As I was preparing the sample for you I figured out a stupid copy-paste mistake.
At the handler of Go2Previous-RadPage I had RadGrid.ReBind() that caused the reset of the Grid and its controls.

Thanks you for your support.
Yoram
Tags
AsyncUpload
Asked by
Yoram
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Yoram
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or