DeleteAllFileInputs (accept the ones that don't validate)

4 posts, 0 answers
  1. Glenn
    Glenn avatar
    47 posts
    Member since:
    Nov 2011

    Posted 01 Apr 2014 Link to this post

    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



  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 04 Apr 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Glenn
    Glenn avatar
    47 posts
    Member since:
    Nov 2011

    Posted 08 Apr 2014 in reply to Hristo Valyavicharski Link to this post

    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?
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 11 Apr 2014 Link to this post

    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.

     
Back to Top