Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Issue: Multiple AjaxFileUpload on same page fires allways the same event [27175]

$
0
0
When I have multiples AjaxFileUpload controls on the same page, the event fired is always the same.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
onuploadcomplete="AjaxFileUpload1_UploadComplete" AllowedFileTypes=""
ContextKeys="1" MaximumNumberOfFiles="0" />
<asp:AjaxFileUpload ID="AjaxFileUpload2" runat="server"
MaximumNumberOfFiles="0" OnUploadComplete="AjaxFileUpload2_UploadComplete"
ContextKeys="2" />
<asp:AjaxFileUpload ID="AjaxFileUpload3" runat="server"
MaximumNumberOfFiles="0" OnUploadComplete="AjaxFileUpload3_UploadComplete"
ClientIDMode="AutoID" ContextKeys="3" />


</form>
</body>
</html>

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
//Only this event is fired, and allways with id=AjaxFileUpload1 and ContextKeys=1
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
AjaxFileUpload aj = sender as AjaxFileUpload;
string id = aj.ID;
string ContextKeys = aj.ContextKeys;
}
protected void AjaxFileUpload3_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{

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

}
}
Comments: Further, perhaps the code can use UserControl.Response instead of Page.Response? http://msdn.microsoft.com/en-us/library/system.web.ui.usercontrol.response%28v=vs.110%29.aspx Something like that.. but I cannot make a firm recommendation since I'm not an AJAX expert. Surely someone can look at the code and remove the assumption that each page will only contain one AjaxUploadControl? This is causing headaches for a lot of people. Thanks!!

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>