javascript – 我想在ajaxToolkit:AjaxFileUpload开始上传时显示一条消息,有没有办法做到这一点
作者:互联网
我想在ajaxToolkit:AjaxFileUpload开始上传时发出消息,有没有办法做到这一点
解决方法:
默认情况下,AjaxFileUpload没有此类事件.但由于AjaxControlToolkit是一个开源库,您可以自己添加它.从此页面下载最近的库源:source codes,找到AjaxFileUpload控件源(/ Server / AjaxControlToolkit / AjaxFileUpload文件夹)并将以下代码添加到AjaxFileUpload.cs文件中:
[DefaultValue("")]
[Category("Behavior")]
[ExtenderControlEvent]
[ClientPropertyName("uploadStarted")]
public string OnClientUploadStarted
{
get
{
return (string)(ViewState["OnClientUploadStarted"] ?? string.Empty);
}
set
{
ViewState["OnClientUploadStarted"] = value;
}
}
之后,修改AjaxFileUpload.pre.js文件:
// 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();
}
比构建解决方案和享受新功能.
标签:jquery,javascript,asp-net,ajaxcontroltoolkit 来源: https://codeday.me/bug/20190626/1289346.html