I see you have uploadComplete for the client side event after uploaded successfully. In this function, you make an __doPostBack call to the server. So it is likely that UploadedComplete is called first time, and then the __doPostBack makes it called again.
Thanks for this but I'm not sure that is the problem. The _doPostback just postbacks an update panel containing a list of the uploaded files. It doesn't contain anything else.
london24
Member
97 Points
108 Posts
AjaxControlToolkit.AsyncFileUploadEventArgs UploadedComplete gets fired twice
Jul 12, 2012 09:29 PM|LINK
Hi
The UploadedComplete for the AjaxControlToolkit.AsyncFileUploadEventArgs gets fired twice (code below)
I have looked on google and it seems this is a common problem but there is no solution that I have found. Can anyone help or is this a bug?
Thanks
java:
<
script type="text/javascript">
function uploadComplete() { //Postback is necessary for asyncfileupload
__doPostBack(
'upFiles', '');
}
</
script>
.aspx code:
<
tr>
<
td class=formRight>Attach File(s):</td>
<
td class=formLeft> <table class=formTable>
<tr>
<td class=formLeft><asp:AsyncFileUpload ID="AsyncFileUpload1" onuploadedcomplete="UploadedComplete" OnClientUploadComplete="uploadComplete" runat="server" ThrobberID=throbber CompleteBackColor="#ccff99" /></td>
<td class=formleft><asp:Label ID="throbber" style="display:none" runat="server"><img align="absmiddle" alt="loading" src="../../Images/ajax-loader.gif" /></asp:Label></td>
</tr>
<tr>
<td class=formleft colspan=2>
<
asp:UpdatePanel ID=upFiles runat=server>
<
ContentTemplate>
<
asp:GridView runat=server ID=gvFiles AutoGenerateColumns="False" GridLines=none borderColor="#ece9d8" ShowHeader=false>
<
RowStyle cssclass=gvRows/>
<
Columns>
<
asp:TemplateField>
<
ItemTemplate>
<
asp:Label ID=lbFileName runat=server Text='<%# Eval("FileName")%>'></asp:Label>
</
ItemTemplate>
</
asp:TemplateField>
<
asp:TemplateField>
<
ItemTemplate>
<
asp:imagebutton id=ibDelete runat=server CommandArgument='<%# Eval("FileName")%>' CommandName="DeleteFile" ImageUrl="~/Images/RedCross.gif" CausesValidation=false></asp:imagebutton>
</
ItemTemplate>
</
asp:TemplateField>
</Columns>
</
asp:GridView>
</
ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="gvFiles" />
</Triggers>
</
asp:UpdatePanel>
</td>
</tr>
</table>
</
td>
</
tr>
and vb code:
Sub UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
System.Threading.
Thread.Sleep(250)
If (AsyncFileUpload1.HasFile) Then
Dim strPath As String = System.IO.Path.GetFileName(e.FileName)
AsyncFileUpload1.SaveAs(Server.MapPath(
"..\..\Files\" + Master.AccountId + "\ArticleFile\" + ViewState("ArticleGuid").ToString + "_" + strPath))
GeneralFunctions.saveArticleFile(Master.AccountId, strPath, ViewState("ArticleGuid").ToString)
getFiles(strPath)
End If
End Sub
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: AjaxControlToolkit.AsyncFileUploadEventArgs UploadedComplete gets fired twice
Jul 13, 2012 03:24 AM|LINK
Hi, Please refer this
http://forums.asp.net/p/1479864/3452356.aspx
http://forums.asp.net/p/1597844/4056650.aspx
http://forums.asp.net/t/1479689.aspx/1
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
london24
Member
97 Points
108 Posts
Re: AjaxControlToolkit.AsyncFileUploadEventArgs UploadedComplete gets fired twice
Jul 13, 2012 07:36 AM|LINK
Hi Thanks but none of the links solve the problem of the event firing twice. I can only assume this is a bug with the asyncfileupload event?
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: AjaxControlToolkit.AsyncFileUploadEventArgs UploadedComplete gets fired twice
Jul 16, 2012 01:58 AM|LINK
Hello
I see you have uploadComplete for the client side event after uploaded successfully. In this function, you make an __doPostBack call to the server. So it is likely that UploadedComplete is called first time, and then the __doPostBack makes it called again.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
london24
Member
97 Points
108 Posts
Re: AjaxControlToolkit.AsyncFileUploadEventArgs UploadedComplete gets fired twice
Jul 16, 2012 07:24 AM|LINK
Thanks for this but I'm not sure that is the problem. The _doPostback just postbacks an update panel containing a list of the uploaded files. It doesn't contain anything else.