本文介绍了我想说明一个消息时ajaxToolkit:AjaxFileUpload开始上传,有没有办法做到这一点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要邮件时ajaxToolkit:AjaxFileUpload开始上传,有没有办法做到这一点。

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

推荐答案

默认情况下 AjaxFileUpload 不具备这样的事件。但随着AjaxControlToolkit是一个开放源码库,你可以自己添加。从这个页面下载最新的库来源:,发现出AjaxFileUpload控制源(/服务器/ AjaxControlToolkit / AjaxFileUpload文件夹),下面添加到AjaxFileUpload.cs文件code:

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;
    }
}

在这之后,修改 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();
}

不是构建解决方案,并与新的功能享受。

Than build solution and enjoy with new functionality.

这篇关于我想说明一个消息时ajaxToolkit:AjaxFileUpload开始上传,有没有办法做到这一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:01