I have a standard AjaxFileUpload control
<asp:AjaxFileUpload ID="upManager" CssClass="fileUpload" runat="server" OnUploadComplete="upManager_UploadComplete" />
And instead of them having to press Upload, I just want the file to upload automatically once they have selected the file. Is there a way to do this?
Add reference to this script to Scripts
collection of ToolkitScriptManager
control or just put it at very bottom of 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 console at this page: AjaxFileUpload Demonstration
Also, in my opinion should be better to tweak ACT sources and add new property like UploadAutomatically
to this control. Let me know if you'll prefer this option and need additional details about how to to such staff
UPDATED: try this script for new AjaxFileUpload (must work for new and old versions but not tested yet)
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();
}
};
}
this works in the newest control toolkit
<asp:AjaxFileUpload onchange="$('.ajax__fileupload_uploadbutton').trigger('click');" runat="server" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With