AjaxFileUpload automatically downloads a file after selecting it

I have a standard AjaxFileUpload control

<asp:AjaxFileUpload ID="upManager" CssClass="fileUpload" runat="server" OnUploadComplete="upManager_UploadComplete" /> 

And instead of clicking Upload, I just want the file to load automatically as soon as they select the file. Is there any way to do this?

+6
source share
3 answers

Add a link to this Scripts collection of ToolkitScriptManager control or simply place it at the very bottom of the page:

 var legacyAddToQueue = Sys.Extended.UI.AjaxFileUpload.prototype._addToQueue; Sys.Extended.UI.AjaxFileUpload.prototype._addToQueue = function(element){ legacyAddToQueue.apply(this, [element]); this._doUpload(); } 

Works well from the console on this page: AjaxFileUpload Demo

In addition, in my opinion, it is better to configure ACT sources and add a new property of type UploadAutomatically to this element. Let me know if you prefer this option and you need more information about how to contact such employees.

UPDATED: try this script for the new AjaxFileUpload (should work for new and old versions, but not yet verified)

 if (Sys.Extended.UI.AjaxFileUpload.prototype._addToQueue) { var legacyAddToQueue = Sys.Extended.UI.AjaxFileUpload.prototype._addToQueue; Sys.Extended.UI.AjaxFileUpload.prototype._addToQueue = function (element) { legacyAddToQueue.apply(this, [element]); this._doUpload(); }; }else if(Sys.Extended.UI.AjaxFileUpload.Control){ var legacyaddFileToQueue = Sys.Extended.UI.AjaxFileUpload.Control.prototype.addFileToQueue; Sys.Extended.UI.AjaxFileUpload.Control.prototype.addFileToQueue = function(fileItem){ if(legacyaddFileToQueue.apply(this, [fileItem])){ this._isUploading = true; this.enableControls(this._isUploading); this._processor.startUpload(); } }; } 
+4
source

it works in the latest management toolkit

 <asp:AjaxFileUpload onchange="$('.ajax__fileupload_uploadbutton').trigger('click');" runat="server" /> 
+3
source

you're right. Just replace it with

 $(".ajax__fileupload").bind("change", function () { setTimeout(function () { $('.ajax__fileupload_uploadbutton').trigger('click'); }, 100); }); $(".ajax__fileupload_dropzone").bind("drop", function () { setTimeout(function () { $('.ajax__fileupload_uploadbutton').trigger('click'); }, 100); }); 
0
source

All Articles