4

I want to a message when ajaxToolkit:AjaxFileUpload start uploading, is there a way to do this

Sarawut Positwinyu
  • 4,974
  • 15
  • 54
  • 80
  • Have a look at this article which might help you **http://dhtmlx.com/docs/products/dhtmlxVault/index.shtml**.. Also as an alternate this might be a good start **http://stackoverflow.com/questions/2714507/jquery-ajax-upload-with-progress-bar-no-flash** – huMpty duMpty Jul 27 '12 at 10:49

2 Answers2

4

By default AjaxFileUpload doesn't have such event. But as the AjaxControlToolkit is an open-source library, you can add it yourself. Download the recent library sources from this page: source codes, find out AjaxFileUpload control sources (/Server/AjaxControlToolkit/AjaxFileUpload folder) and add code below to the AjaxFileUpload.cs file:

[DefaultValue("")]
[Category("Behavior")]
[ExtenderControlEvent]
[ClientPropertyName("uploadStarted")]
public string OnClientUploadStarted
{
    get
    {
        return (string)(ViewState["OnClientUploadStarted"] ?? string.Empty);
    }
    set
    {
        ViewState["OnClientUploadStarted"] = value;
    }
}

after that, modify AjaxFileUpload.pre.js file:

// insert this code right after the _raiseUploadComplete method
add_uploadStarted: function (handler) {
    this.get_events().addHandler("uploadStarted", handler);
},

remove_uploadStarted: function (handler) {
    this.get_events().removeHandler("uploadStarted", handler);
},

_raiseUploadStarted: function () {
    var eh = this.get_events().getHandler("uploadStarted");
    if (eh) {
        eh(this, Sys.EventArgs.Empty);
    }
},

// modify the _doUpload method
_doUpload: function () {

    if (!this._filesInQueue.length || this._filesInQueue.length < 1)
        return;

    this._raiseUploadStarted();

    this._currentQueueIndex = -1;
    if (!this._isFileApiSupports)
        this._createIframe();

    this._processNextFile();
}

Than build solution and enjoy with new functionality.

Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68
0

In current version (December 2013 Release Version 7.1213) of AjaxControlToolkit this event is availbale without any need for any source code modifications.

http://ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Server/AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs

100r
  • 1,099
  • 1
  • 12
  • 24