ajax工具包文件上传不调用 [英] Ajax toolkit file upload is not called

查看:30
本文介绍了ajax工具包文件上传不调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个页面上有两个 ajaxtoolkit 文件 ulopads,比如

I have two ajaxtoolkit file ulopads on the same page like

 <ajaxToolkit:AjaxFileUpload
        id="AjaxFileUpload1"
        AllowedFileTypes="jpg,jpeg,gif,png"
        OnUploadComplete="ajaxUpload2_OnUploadComplete"
        runat="server"  />
         <ajaxToolkit:AjaxFileUpload
        id="ajaxUpload1"
        AllowedFileTypes="jpg,jpeg,gif,png"
        OnUploadComplete="ajaxUpload1_OnUploadComplete"
        runat="server"  />

和后面的代码

protected void ajaxUpload2_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {

        string filePath = "~/Images/" + e.FileName;
        filePath = filePath.Split('\').Last();
        Session["img2"] = filePath.ToString();
        AjaxFileUpload1.SaveAs(MapPath(filePath));

    }

    protected void ajaxUpload1_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {

        string filePath = "~/Images/" + e.FileName;
        filePath = filePath.Split('\').Last();
        Session["img1"] = filePath.ToString();
        ajaxUpload1.SaveAs(MapPath(filePath));

    }

问题是,每当我使用上传 AjaxFileUpload1 时,它都会工作并调用 void ajaxUpload2_OnUploadComplete 方法,但是如果我使用 ajaxUpload1 方法 ajaxUpload2_OnUploadComplete 会再次调用,但不会调用 ajaxUpload1 方法

The question is whenever I use upload AjaxFileUpload1 it works on and calls void ajaxUpload2_OnUploadComplete method but if I use ajaxUpload1 the method ajaxUpload2_OnUploadComplete is called again but the method ajaxUpload1 is not called

为什么??

谢谢.

推荐答案

我们昨天遇到了同样的问题,我们发现你不能拥有多个 AjaxFileUpload 的实例 在同一页面上.

We got the same problem yesterday and we found out that you cannot have more than one instance of AjaxFileUpload on the same page.

如果您查看源代码,您会看到此控件使用常量 GUID 来标识其事件.由于GUID 是一个常量,所有AjaxFileUpload 的实例都使用相同的GUID...

If you look at the source code, you'll see that this control use a constant GUID to identify its events. Since the GUID is a constant, all instances of AjaxFileUpload use the same GUID...

结果:

第一个实例吞下所有事件...

the first instance swallow all the events...

这是正在运行的 GUID :

Here is the GUID in action :

private const string ContextKey = "{DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}";

(...)

if (this.Page.Request.QueryString["contextkey"] == ContextKey && this.Page.Request.Files.Count > 0)

这篇关于ajax工具包文件上传不调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆