Upload Box message

Hi,
Is there a way to fire a javascript function after hitting the close button on the upload box after uploading a file(I would like to update my form with a message to the user)?
Also, if the upload fails, is there a way to update my form with the error message?
My application is using mvc with c#.
Thanks.

1 Reply

PO Prince Oliver Syncfusion Team October 30, 2017 08:02 AM UTC

Hi Richard, 

Thank you for contacting Syncfusion forums. 

In the uploadbox control, we can use the success event to get the file name that is successfully uploaded and display it in the form. Similary you can use the error event to get the error message and the file name and display it in the form. Kindly refer to the following code:  

<div class="posupload"> 
@Html.EJ().Uploadbox("UploadDefault").SaveUrl("SaveDefault").RemoveUrl("RemoveDefault").ClientSideEvents(e=>e.Success("onsuccess").Error("onerror")) 
</div> 
<br /><br /> 
<div id="msg"></div> 
<script> 
    function onsuccess(args) { 
        $("#msg").html(""); 
        var msg = "<span class='green'> <b style='color:green;'>Success - </b>" + args.files.name + "</span>" 
        $("#msg").append(msg); 
    } 
    function onerror(args) { 
        $("#msg").html(""); 
        var msg = "<span class='red'> <b style='color:red;'>Failed - </b>" + args.error + " - " + args.files.name + " </span>"; 
        $("#msg").append(msg); 
    } 
</script> 

We have prepared a sample for your convenience, kindly refer to the following link for the sample: http://www.syncfusion.com/downloads/support/forum/133450/ze/FileUploadMessage1477233854 

Regards, 
Prince 


Loader.
Up arrow icon