UploadBox - how to send a custom statut code to OnComplete callback function ?

Hello,
 
How to send a custom statut code (action controller) to OnComplete callback function ?
 
Moreover, how can I check file size prior uploading it (by property max file size) ?
 
Thanks,
 
Jacques Duclos

1 Reply

VR Varalakshmi R.S Syncfusion Team March 19, 2013 10:36 AM UTC

Hi Jacques Duclos,

 

Thanks for contacting Syncfusion forums.

 

Query 1:

You can send the custom status to controller by triggering ajax post on upload complete event. Please refer the below given code snippet,

<code>

[View]

@{Html.Syncfusion().UploadBox("upload")

 

    .AsyncUpload(

        a =>

            a.SaveAction("Save", "Home")

            .RemoveAction("Remove", "Home")

 

         ).ClientSideOnComplete("ClientSideOnComplete").ClientSideOnSelect("ClientSideOnSelect").Render();}

[Script]

 

function ClientSideOnComplete(sender, args) {

//Pass status as arguments in data

        $.ajax({

            type: "post",

            url: "Home/Index",

            data: { "args": "Custom Status" },

            dataType: 'html',

            success: function (data) {

 

            }

 

        });

    }

 [Controller]

[HttpPost]

        public ActionResult Index(string args)

        {

//args hold the value sent from script

            return View();

        }

 

</code>

Query 2:

The size of the file can be retrieved in the event “ClientSideOnSelect” from its argument “args[0].size”. please refer the below given code snippet,

<code>

[Script]

function ClientSideOnSelect(sender, args) {

        alert(args[0].size);

    }

</code>

Note : To retrieve the file size in IE, you must enable the ActiveXcontrols using the below given option,

Tools->IE options-> Security->Trusted Sites->Custom level->Initialize and script ActiveX controls not marked as safefor scripting->Enable.

 

Kindly try the above solutions and let us know if this helps.

 

Regards,

Varalakshmi

Loader.
Up arrow icon