【问题标题】:Two AjaxFileUpload controls entering the same UploadComplete function两个 AjaxFileUpload 控件进入同一个 UploadComplete 函数
【发布时间】:2013-07-14 22:47:01
【问题描述】:

我试图在同一页面中使用两个 Ajaxfileupload 控件,但都输入相同的上传完成功能,我不知道为什么.. (他们进入“AjaxFileUpload1_UploadComplete”函数)

这是我的 aspx 部分:

<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="AjaxFileUpload1_UploadComplete" ThrobberID="myThrobber" MaximumNumberOfFiles="10" AllowedFileTypes="jpg,jpeg"/>        

<asp:AjaxFileUpload ID="AjaxFileUpload2" runat="server" OnUploadComplete="AjaxFileUpload1_prof_pic" ThrobberID="myThrobber" MaximumNumberOfFiles="1" AllowedFileTypes="jpg,jpeg"/>   

这是我的代码:

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

        Directory.CreateDirectory(Server.MapPath("~/Member_Data/" + id + "/images/"));
        string filePath = "~/Member_Data/" + id + "/images/";
        string path = filePath + e.FileName;
        AjaxFileUpload1.SaveAs(Server.MapPath(filePath) + e.FileName);

        db1.insert_pic_slide(id, path);

        string qstring = "?id=" + id;

        //Response.Redirect("profile_layout.aspx" + qstring);

    }

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

        Directory.CreateDirectory(Server.MapPath("~/Member_Data/" + id + "/images/"));
        string filePath = "~/Member_Data/" + id + "/images/";
        string path = filePath + e.FileName;
        AjaxFileUpload2.SaveAs(Server.MapPath(filePath) + e.FileName);

        db1.insert_pic(id, path);

        string qstring = "?id=" + id;

        Response.Redirect("profile_layout.aspx" + qstring);


    }

【问题讨论】:

标签: c# asp.net file-upload ajaxcontroltoolkit ajaxuploader


【解决方案1】:

我也遇到了同样的问题,所以我只是删除了第二个 Ajaxfileupload 控件,然后根据下拉选择的值上传文件。我只是使用单个文件上传控件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    相关资源
    最近更新 更多