两个AjaxFileUpload控件进入相同的UploadComplete函数
本文关键字:UploadComplete 函数 AjaxFileUpload 控件 两个 | 更新日期: 2023-09-27 18:22:44
我试图在同一页面中使用两个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);
}
我也面临同样的问题,所以我删除了第二个Ajaxfileupload控件,并根据下拉选择的值上传文件。我只是使用单个文件上传控制。