两个AjaxFileUpload控件进入相同的UploadComplete函数

时间:2013-07-16 16:19:47

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

我正在尝试在同一页面中使用两个Ajaxfileupload控件,但两者都输入相同的uploadcomplete函数,我不知道为什么.. (他们输入“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);


    }

1 个答案:

答案 0 :(得分:1)

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