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

DeleteAllFileInputs (accept the ones that don't validate)

3 Answers 61 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Glenn
Top achievements
Rank 1
Glenn asked on 01 Apr 2014, 05:25 AM
Using AsyncUpload that previews images via a radlistview before user selects final upload (also allowing image removal)

Using the following javascript to delete all file inputs so as not to show the normal message upon file selection:
function filesUploaded(sender, args) {$find("<%= RadAjaxPanel1.ClientID%>").ajaxRequest() sender.deleteAllFileInputs(); //cleans up any not removed from fileuploaded   }

Have also added client side validation as per this great demo:  http://demos.telerik.com/aspnet-ajax/asyncupload/examples/validation/defaultvb.aspx

All works well accept that the error messages will only appear if user is only uploading one or many files that are all invalid.  When using multiple file upload if one of the files is valid, the function mentioned above with deleteAllFileInputs appears to remove the files with error messages as well (by design, I'd imagine). 
I'd obviously like the user to see the files with error messages only.
Is there any way to limit deleteAllFileInputs to just the validated files?

Thanks

Glenn



3 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 04 Apr 2014, 07:34 AM
Hi Glenn,

Try to handle and cancel the OnClientFileUploadRemoving event:

function OnClientFileUploadRemoving(sender, args) {
      if (args.get_fileName() == "test.jpg") {
          args.set_cancel(true);
      }
}

it should be fired after you call deleteAllFileInputs().

Regards,
Hristo Valyavicharski
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
Glenn
Top achievements
Rank 1
answered on 08 Apr 2014, 07:35 AM
Thanks but I was mistaken: sender.deleteAllFileInputs() in my function isn't being used.  The $find("<%= RadAjaxPanel1.ClientID%>").ajaxRequest() appears to be removing the file error messages when ajax request posts back to add the valid files to the radlistview in Protected Sub AsyncUpload2_FileUploaded.

I can't figure out how to get the error messages to stay visible after returning from the ajax request.  Any suggestions?
0
Hristo Valyavicharski
Telerik team
answered on 11 Apr 2014, 07:22 AM
Hi Glenn,

Where do you display the notification message? Try to put it inside Label or other server control and add AjaxSetting where the AjaxManager will update the Label:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="lblMessage" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

Or put all controls (upload, label with the message and the submit button) inside one ASP.NET panel and add the same AjaxSetting, where the AjaxManager updates the ASP.NET panel.

I hope this helps.

Regards,
Hristo Valyavicharski
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.

 
Tags
AsyncUpload
Asked by
Glenn
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Glenn
Top achievements
Rank 1
Share this question
or