AsyncFileUpload : OnUploadedComplete not firinghttp://forums.asp.net/t/1479689.aspx/1?AsyncFileUpload+OnUploadedComplete+not+firingSun, 13 Feb 2011 04:27:41 -050014796893450117http://forums.asp.net/p/1479689/3450117.aspx/1?AsyncFileUpload+OnUploadedComplete+not+firingAsyncFileUpload : OnUploadedComplete not firing <p>Hi,</p> <p><br> </p> <p>I use a FormView as a detailview of a GridView to show and edit data.</p> <p>The FormView is in an UpdatePanel and shown with a ModalPoupController on an event of the GridView.</p> <p>In this FormView, when in EditMode, I want to be able to upload an image and display it, so I've put an AsyncFileUpload in the EditItemTemplate of my FormView.</p> <p>The OnClientUploadComplete event is fired but the OnUploadedComplete event is never fired.</p> <p>I have almost the same page with a FormView in InsertMode and it works great, but this FormView is not in an UpdatePanel.</p> <p>Any idea on how to save the uploaded image on the server if OnUploadedComplete cannot be fired, or, of course, how to make this event to fire ?</p> <p><br> </p> <p>Thanks for your help.<br> </p> 2009-10-09T13:31:04-04:003457917http://forums.asp.net/p/1479689/3457917.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Hi sovitec,</p> <p>To display the image after the UploadedComplete event is fired, we need to register a script which is used to set the images src property.</p> <p>Please test my sample here. The UploadedComplete event can be fired whether the AsyncFileUpload control inside an UpdatePanel or not.</p> <pre class="prettyprint">&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;TestUploadedCompleteEvent.aspx.cs&quot; Inherits=&quot;SoluTest_AsyncFileUpload.TestUploadedCompleteEvent&quot; %&gt; &lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;cc1&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head runat=&quot;server&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;script runat=&quot;server&quot;&gt; protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), &quot;size&quot;, &quot;top.$get(\&quot;&quot; &#43; uploadResult.ClientID &#43; &quot;\&quot;).innerHTML = 'Uploaded size: &quot; &#43; AsyncFileUpload1.FileBytes.Length.ToString() &#43; &quot;';&quot;, true); string savePath = MapPath(&quot;~/Uploads/&quot; &#43; System.IO.Path.GetFileName(e.filename)); AsyncFileUpload1.SaveAs(savePath); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), &quot;image&quot;, &quot;top.$get(\&quot;&quot; &#43; Image1.ClientID &#43; &quot;\&quot;).src = 'Uploads/&quot; &#43; System.IO.Path.GetFileName(e.filename) &#43; &quot;';&quot;, true); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot; /&gt; &lt;asp:UpdatePanel ID=&quot;UpdatePanel1&quot; runat=&quot;server&quot;&gt; &lt;ContentTemplate&gt; Please upload a image:&lt;br /&gt; &lt;cc1:AsyncFileUpload ID=&quot;AsyncFileUpload1&quot; runat=&quot;server&quot; OnUploadedComplete=&quot;AsyncFileUpload1_UploadedComplete&quot; /&gt; &lt;br /&gt; &lt;br /&gt; Here is your image:&lt;br /&gt; &lt;asp:Label runat=&quot;server&quot; Text=&quot; &quot; ID=&quot;uploadResult&quot; /&gt;&lt;br /&gt; &lt;asp:Image ID=&quot;Image1&quot; runat=&quot;server&quot; /&gt;&lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><br> Have it helped?</p> <p>Best regards,</p> <p>Zhi-Qiang Ni</p> 2009-10-14T13:35:37-04:003458225http://forums.asp.net/p/1479689/3458225.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Thanks for your answer. Unfortunately this is the OnUploadedComplete that is not fired, OnClientUploadCompleteworks in every case.<br> </p> 2009-10-14T15:50:37-04:003459032http://forums.asp.net/p/1479689/3459032.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>There is no <strong>UploadComplete</strong> event. There are <strong>OnUploadedComplete</strong> and <strong>OnClientUploadComplete</strong> events.<br> What from them does not work?</p> 2009-10-15T03:17:57-04:003459394http://forums.asp.net/p/1479689/3459394.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Ooops, sorry, <b>OnUploadedComplete</b> does not work, <b>OnClientUploadComplete</b> that I've mistakenly called UploadComplete if firing correctly.</p> <p><br> </p> <p>Thanks for your help<br> </p> 2009-10-15T08:18:36-04:003459423http://forums.asp.net/p/1479689/3459423.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Why have you decided that <b>OnUploadedComplete</b> does not work?<br> It doesn't change the <strong>UpdatePanel</strong> ?&nbsp;</p> 2009-10-15T08:39:38-04:003459531http://forums.asp.net/p/1479689/3459531.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>I did not decide anything <img src="http://forums.asp.net/tiny_mce/jscripts/tiny_mce/plugins/emotions/img/smiley-wink.gif" alt="Wink" title="Wink" border="0">, it's just that nothing happens. Putting a breakpoint at the beginning of the function called by <b>OnUploadedComplete</b> shows that this function is never called.<br> </p> <p><br> </p> 2009-10-15T09:38:26-04:003459536http://forums.asp.net/p/1479689/3459536.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Hi sovitec,</p> <p>Is your code similar to mine? Please test my code firstly. </p> <p>Or please post your code snippet here to help us reproduce it.</p> <p>Best regards,</p> <p>Zhi-Qiang Ni</p> 2009-10-15T09:43:23-04:003459943http://forums.asp.net/p/1479689/3459943.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p></p> <blockquote><span class="icon-blockquote"></span> <h4>obout_teo</h4> <p>...</p> <p>It doesn't change the <strong>UpdatePanel</strong> ?&nbsp;</p> <p></p> </blockquote> &nbsp; <p></p> <p>&nbsp;</p> <p>This is the problem in my case. Can you point me in the right direction?</p> <p>The AsyncFileUpload i placed in&nbsp;a UpdatePanel with Updatemode=&quot;Always&quot;.&nbsp;&nbsp;It is not a nested UpdatePanel.</p> <p>This is how the code-behind looks:</p> <pre class="prettyprint">Protected Sub File1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles File1.UploadedComplete lblStatus.Text = &quot;Done!&quot; End Sub</pre> <p>&nbsp;</p> <p>The thing is, lblStatus does not show the new value &quot;Done!&quot;. I can put a breakpoint in the above code and it&nbsp;works as usual.<br> What can be the problem?</p> <p>&nbsp;</p> <p><br> &nbsp;</p> <p>&nbsp;</p> <p><br> &nbsp;</p> 2009-10-15T13:11:15-04:003461051http://forums.asp.net/p/1479689/3461051.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Your&nbsp;changes the UpdatePanel in a temporary iframe used for async uploading.<br> Do the following:<br> </p> <pre class="prettyprint">Protected Sub File1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles File1.UploadedComplete ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), &quot;reply&quot;, &quot;top.$get('&quot; &amp; lblStatus.ClientID &amp; &quot;').innerHTML= 'Done!';&quot;, True) End Sub</pre> <p><br> <br> &nbsp;</p> 2009-10-16T01:18:00-04:003461443http://forums.asp.net/p/1479689/3461443.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Great! Thanks a lot, your solution&nbsp;works like a charm!</p> 2009-10-16T07:52:14-04:003465245http://forums.asp.net/p/1479689/3465245.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Here is a simplified version of my broken code, I hope someone can understand what is wrong.<pre class="prettyprint">&lt;%@ Page Language=&quot;C#&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;cc1&quot; %&gt; &lt;script runat=&quot;server&quot;&gt; protected void AsyncFileUploadLogo_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { // !!!!!!!!!!!!! This part is never call !!!!!!!!!!!!!!!!!!!! ((AjaxControlToolkit.AsyncFileUpload)sender).SaveAs(Server.MapPath(Request.ApplicationPath &#43; e.filename)); } protected void ObjectDataSourceHeadingDetails_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { // set the input parameter to the value of the selected index if (this.GridViewHeadings.SelectedIndex &gt;= 0) e.InputParameters[&quot;HeadingID&quot;] = Convert.ToString(this.GridViewHeadings.DataKeys[this.GridViewHeadings.SelectedIndex].Value); } protected void GridViewHeadings_SelectedIndexChanged(object sender, EventArgs e) { // Display data in simple view mode this.FormViewHeadingDetails.ChangeMode(FormViewMode.ReadOnly); // Set visibility to true so Formview will render this.FormViewHeadingDetails.Visible = true; // Force databinding this.FormViewHeadingDetails.DataBind(); // Update the contents in the detail panel this.UpdatePanelHeadingDetails.Update(); // Show the modal popup this.ModalPopupExtenderHeadingDetails.Show(); } protected void GridViewHeadings_RowCommand(Object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case &quot;EditHeading&quot;: // Display data in update view mode this.FormViewHeadingDetails.ChangeMode(FormViewMode.Edit); // Set visibility to true so Formview will render this.FormViewHeadingDetails.Visible = true; // Force databinding GridViewHeadings.SelectedIndex = Convert.ToInt32(e.CommandArgument); this.FormViewHeadingDetails.DataBind(); // Update the contents in the detail panel this.UpdatePanelHeadingDetails.Update(); // Define ImageLogo and HiddenFieldLogo in Javascript so they can be used to update image string script = &quot;var ImageLogo = '&quot; &#43; FormViewHeadingDetails.FindControl(&quot;ImageLogo&quot;).ClientID &#43; &quot;'; var HiddenFieldLogo = '&quot; &#43; FormViewHeadingDetails.FindControl(&quot;HiddenFieldLogo&quot;).ClientID &#43; &quot;'; var ButtonUploadLogo = '&quot; &#43; FormViewHeadingDetails.FindControl(&quot;ButtonUploadLogo&quot;).ClientID &#43; &quot;';&quot;; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), &quot;UploadComplete&quot;, script, true); //AjaxControlToolkit.AsyncFileUpload AsyncFileUploadLogo = new AjaxControlToolkit.AsyncFileUpload(); //AsyncFileUploadLogo.UploadedComplete &#43;= new EventHandler&lt;AjaxControlToolkit.AsyncFileUploadEventArgs&gt;(AsyncFileUploadLogo_UploadedComplete); //AsyncFileUploadLogo.OnClientUploadComplete = &quot;UploadComplete&quot;; //AsyncFileUploadLogo.UploaderStyle = AjaxControlToolkit.AsyncFileUpload.UploaderStyleEnum.Traditional; //AsyncFileUploadLogo.ThrobberID = &quot;ImageThrobber&quot;; //HtmlTableCell td = (HtmlTableCell)FormViewHeadingDetails.FindControl(&quot;CellUploadLogo&quot;); //td.Controls.Add(AsyncFileUploadLogo); // Show the modal popup this.ModalPopupExtenderHeadingDetails.Show(); break; } } protected void ButtonValidateHeading_Click(object sender, EventArgs e) { if (this.Page.IsValid) { // Move the data back to the data object FormViewHeadingDetails.UpdateItem(false); // Hide the modal popup ModalPopupExtenderHeadingDetails.Hide(); //// Refresh the grid so we can see our changed GridViewHeadings.DataBind(); UpdatePanelHeadings.Update(); } } &lt;/script&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head runat=&quot;server&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&quot;text/javascript&quot;&gt; function UploadComplete(sender, args) { $get(HiddenFieldLogo).value = args.get_fileName(); $get(ImageLogo).src = args.get_fileName(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;cc1:ToolkitScriptManager ID=&quot;ToolkitScriptManager1&quot; runat=&quot;server&quot; /&gt; &lt;asp:LinqDataSource ID=&quot;LinqDataSourceHeadings&quot; runat=&quot;server&quot; ContextTypeName=&quot;ShopsDataContext&quot; TableName=&quot;Headings&quot; /&gt; &lt;asp:ObjectDataSource ID=&quot;ObjectDataSourceHeadingDetails&quot; runat=&quot;server&quot; TypeName=&quot;DataSourceHeadingDetails&quot; SelectMethod=&quot;Select&quot; UpdateMethod=&quot;Update&quot; OnSelecting=&quot;ObjectDataSourceHeadingDetails_Selecting&quot; /&gt; &lt;div&gt; &lt;asp:UpdatePanel ID=&quot;UpdatePanelHeadings&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:GridView ID=&quot;GridViewHeadings&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; DataKeyNames=&quot;ID&quot; DataSourceID=&quot;LinqDataSourceHeadings&quot; OnRowCommand=&quot;GridViewHeadings_RowCommand&quot; OnSelectedIndexChanged=&quot;GridViewHeadings_SelectedIndexChanged&quot;&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton ID=&quot;ButtonModify&quot; runat=&quot;server&quot; CommandName=&quot;EditHeading&quot; CommandArgument=&quot;&lt;%# ((GridViewRow) Container).RowIndex %&gt;&quot; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:BoundField DataField=&quot;ID&quot; HeaderText=&quot;ID&quot; InsertVisible=&quot;False&quot; ReadOnly=&quot;True&quot; SortExpression=&quot;ID&quot; Visible=&quot;False&quot; /&gt; &lt;asp:BoundField DataField=&quot;Name&quot; HeaderText=&quot;Name&quot; SortExpression=&quot;Name&quot; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:Button ID=&quot;ButtonModifyHidden&quot; runat=&quot;server&quot; Style=&quot;display: none&quot; /&gt; &lt;cc1:ModalPopupExtender ID=&quot;ModalPopupExtenderHeadingDetails&quot; runat=&quot;server&quot; PopupControlID=&quot;PanelHeadingDetails&quot; TargetControlID=&quot;ButtonModifyHidden&quot; BackgroundCssClass=&quot;modalBackground&quot; /&gt; &lt;asp:Panel ID=&quot;PanelHeadingDetails&quot; runat=&quot;server&quot; SkinID=&quot;PopupPanel&quot; Style=&quot;display: none&quot;&gt; &lt;asp:UpdatePanel ID=&quot;UpdatePanelHeadingDetails&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:FormView ID=&quot;FormViewHeadingDetails&quot; runat=&quot;server&quot; DataSourceID=&quot;ObjectDataSourceHeadingDetails&quot;&gt; &lt;EditItemTemplate&gt; &lt;asp:HiddenField ID=&quot;HiddenFieldID&quot; runat=&quot;server&quot; Value='&lt;%# Bind(&quot;ID&quot;) %&gt;' /&gt; &lt;asp:HiddenField ID=&quot;HiddenFieldLogo&quot; Value='&lt;%# Bind(&quot;Logo&quot;) %&gt;' runat=&quot;server&quot; /&gt; &lt;asp:TextBox ID=&quot;TextBoxName&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Name&quot;) %&gt;' /&gt; &lt;asp:Image ID=&quot;ImageLogo&quot; runat=&quot;server&quot; Width=&quot;48&quot; Height=&quot;48&quot; ImageUrl='&lt;%# Request.ApplicationPath &#43; Eval(&quot;Logo&quot;) %&gt;' /&gt;&lt;br /&gt; &lt;asp:Image ID=&quot;ImageThrobber&quot; runat=&quot;server&quot; SkinID=&quot;Throbber&quot; /&gt; &lt;cc1:AsyncFileUpload ID=&quot;AsyncFileUploadLogo&quot; runat=&quot;server&quot; UploaderStyle=&quot;Traditional&quot; ThrobberID=&quot;ImageThrobber&quot; OnUploadedComplete=&quot;AsyncFileUploadLogo_UploadedComplete&quot; OnClientUploadComplete=&quot;UploadComplete&quot; /&gt; &lt;asp:Button ID=&quot;ButtonValidateHeading&quot; runat=&quot;server&quot; Text=&quot;Save&quot; CausesValidation=&quot;true&quot; OnClick=&quot;ButtonValidateHeading_Click&quot; /&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&quot;LabelHeading&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Name&quot;) %&gt;' /&gt; &lt;asp:Image ID=&quot;ImageLogo&quot; runat=&quot;server&quot; ImageUrl='&lt;%# Request.ApplicationPath &#43; Eval(&quot;Logo&quot;) %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:FormView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre><br> <br> Thank you all for your help<br> </p> 2009-10-19T14:00:26-04:003466184http://forums.asp.net/p/1479689/3466184.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p></p> <blockquote><span class="icon-blockquote"></span> <h4>sovitec</h4> Here is a simplified version of my broken code, I hope someone can understand what is wrong.</blockquote> <br> Could you send me the full project (with all folders and without MS SQL use) that I'll be able to run locally?<br> <p></p> 2009-10-20T01:07:03-04:003472159http://forums.asp.net/p/1479689/3472159.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>What if the scenario is more advanced? I have an AsyncFileUpload with Repeater and Label below, <b>all in UpdatePanel</b>. What I want is to show the list of uploaded files immediately after upload and save. When trying to call the databind procedure in AsyncFileUpload1.UploadedComplete handler (after saving the file), the Repeater stays unchanged. The same result when trying to update a simple Label in UpdatePanel, but I can't figure out the ClientScriptBlock in that complicated case.</p> <p><pre class="prettyprint">Protected Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AsyncFileUpload1.UploadedComplete 'save file System.Threading.Thread.Sleep(2000) If (AsyncFileUpload1.HasFile) Then Dim maxUploadSizeInBytes As Integer = CInt(System.Configuration.ConfigurationManager.AppSettings(&quot;MaxUploadSizeInBytes&quot;)) If AsyncFileUpload1.PostedFile.ContentLength &lt; maxUploadSizeInBytes Then Dim strFolder As String = Server.MapPath(&quot;~/Upload/Clanek_&quot; &#43; Me._Clanek.KodClanku.ToString) Try If Not IO.Directory.Exists(strFolder) Then IO.Directory.CreateDirectory(strFolder) Dim strFile As String = strFolder &#43; &quot;\&quot; &#43; IO.Path.GetFileName(e.filename) If IO.File.Exists(strFile) Then IO.File.Delete(strFile) AsyncFileUpload1.SaveAs(strFile) 'here I´m calling the databinding procedure Catch ex As Exception End Try Else 'show a message - e.g. lMessage.Text = &quot;cannot upload&quot; End If End If End Sub</pre><br> <br> </p> <p><br> </p> 2009-10-22T16:30:18-04:003472825http://forums.asp.net/p/1479689/3472825.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>See my post above:<br> <br> </p> <blockquote><span class="icon-blockquote"></span> <h4>obout_teo</h4> Your&nbsp;changes the UpdatePanel in a temporary iframe used for async uploading.<br> <span>&nbsp;</span></blockquote> &nbsp; <p></p> 2009-10-23T00:59:55-04:003473302http://forums.asp.net/p/1479689/3473302.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p></p> <blockquote><span class="icon-blockquote"></span> <h4>obout_teo</h4> <p></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>sovitec</h4> Here is a simplified version of my broken code, I hope someone can understand what is wrong.</blockquote> <br> Could you send me the full project (with all folders and without MS SQL use) that I'll be able to run locally?<br> <p></p> <p></p> </blockquote> <p></p> <p>Sorry, I didn't had time yet to build a working page without confidential data.</p> <p>I guess the problem come from the fact that the AsyncFileUpload component is inside a FormView itself&nbsp; in an UpdatePanel, so it never exist at page startup, it is created on the fly.</p> <p>If you guys think that it's not the problem I will try soon to make a working page showing the problem.</p> <p>Thanks again for your help !<br> </p> 2009-10-23T08:09:56-04:003484040http://forums.asp.net/p/1479689/3484040.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Here's a working page using the Northwind database showing the problem.</p> <p>The page just need to drop the employee table in a dbml.</p> <p>Thank you all for your help.<br> </p> <p><br> </p> <p><pre class="prettyprint">&lt;%@ Page Language=&quot;C#&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt; &lt;title&gt;Test&lt;/title&gt; &lt;script runat=&quot;server&quot;&gt; protected void GvCustomers_SelectedIndexChanged(object sender, EventArgs e) { // set it to true so it will render this.fvCustomerDetail.Visible = true; // force databinding this.fvCustomerDetail.DataBind(); // update the contents in the detail panel this.updPnlCustomerDetail.Update(); // show the modal popup this.mdlPopup.Show(); if (fvCustomerDetail.CurrentMode == FormViewMode.Edit) { string script = &quot;var PhotoImage = '&quot; &#43; fvCustomerDetail.FindControl(&quot;PhotoImage&quot;).ClientID &#43; &quot;'; var PhotoPathHiddenField = '&quot; &#43; fvCustomerDetail.FindControl(&quot;PhotoPathHiddenField&quot;).ClientID &#43; &quot;';&quot;; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), &quot;UploadComplete&quot;, script, true); } } protected void LdsCustomerDetail_Selecting(object sender, LinqDataSourceSelectEventArgs e) { // set the input parameter to the value of the selected index if (this.gvCustomers.SelectedIndex &gt;= 0) e.WhereParameters[&quot;EmployeeID&quot;] = Convert.ToInt32(this.gvCustomers.DataKeys[this.gvCustomers.SelectedIndex].Value); } protected void GvCustomers_RowCommand(Object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case &quot;Select&quot;: switch (e.CommandArgument.ToString()) { case &quot;Edit&quot;: this.fvCustomerDetail.ChangeMode(FormViewMode.Edit); break; case &quot;ReadOnly&quot;: this.fvCustomerDetail.ChangeMode(FormViewMode.ReadOnly); break; } break; } } protected void BtnSave_Click(object sender, EventArgs args) { if (this.Page.IsValid) { // move the data back to the data object this.fvCustomerDetail.UpdateItem(false); this.fvCustomerDetail.Visible = false; // hide the modal popup this.mdlPopup.Hide(); // add the css class for our yellow fade ScriptManager.GetCurrent(this).RegisterDataItem( // The control I want to send data to this.gvCustomers, // The data I want to send it (the row that was edited) this.gvCustomers.SelectedIndex.ToString() ); // refresh the grid so we can see our changed this.gvCustomers.DataBind(); this.updatePanel.Update(); } } protected void AsyncFileUploadLogo_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { ((AjaxControlToolkit.AsyncFileUpload)sender).SaveAs(Server.MapPath(Request.ApplicationPath &#43; &quot;/Photos/&quot; &#43; e.filename)); } &lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; function UploadComplete(sender, args) { alert(&quot;UploadComplete&quot;); $get(PhotoPathHiddenField).value = args.get_fileName(); $get(PhotoImage).src = '&lt;%= Request.ApplicationPath &#43; &quot;/Photos/&quot; %&gt;' &#43; args.get_fileName(); } &lt;/script&gt; &lt;style type=&quot;text/css&quot;&gt; TR.updated TD { background-color: yellow; } .modalBackground { background-color: Gray; filter: alpha(opacity=70); opacity: 0.7; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;asp:ScriptManager ID=&quot;scriptManager&quot; runat=&quot;server&quot; /&gt; &lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt; // attach to the pageLoaded event Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded); function pageLoaded(sender, args) { // the data key is the control's ID var dataKey = '&lt;%= this.gvCustomers.ClientID %&gt;'; var updatedRowIndex = args.get_dataItems()[dataKey]; // if there is a datakey for the grid, use it to // identify the row that was updated if (updatedRowIndex) { // get the row that was updated var tr = $get(dataKey).rows[parseInt(updatedRowIndex) &#43; 1]; // add the 'updated' css class Sys.UI.DomElement.addCssClass(tr, 'updated'); // remove the css class in 1.5 seconds window.setTimeout(function() { Sys.UI.DomElement.removeCssClass( tr, 'updated' ); }, 1500); } } &lt;/script&gt; &lt;asp:LinqDataSource ID=&quot;ldsCustomerList&quot; runat=&quot;server&quot; ContextTypeName=&quot;NorthwindDataContext&quot; TableName=&quot;Employees&quot; Select=&quot;new (EmployeeID, LastName, FirstName, Title, Photo, PhotoPath)&quot;&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:LinqDataSource ID=&quot;ldsCustomerDetail&quot; runat=&quot;server&quot; ContextTypeName=&quot;NorthwindDataContext&quot; Select=&quot;new (EmployeeID, LastName, FirstName, Title, Photo, PhotoPath, Notes)&quot; EnableUpdate=&quot;true&quot; TableName=&quot;Employees&quot; OnSelecting=&quot;LdsCustomerDetail_Selecting&quot; Where=&quot;EmployeeID==@EmployeeID&quot;&gt; &lt;WhereParameters&gt; &lt;asp:Parameter DefaultValue=&quot;0&quot; Name=&quot;EmployeeID&quot; Type=&quot;Int32&quot; /&gt; &lt;/WhereParameters&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:UpdatePanel ID=&quot;updatePanel&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:GridView ID=&quot;gvCustomers&quot; runat=&quot;server&quot; DataSourceID=&quot;ldsCustomerList&quot; AutoGenerateColumns=&quot;False&quot; OnSelectedIndexChanged=&quot;GvCustomers_SelectedIndexChanged&quot; BackColor=&quot;White&quot; BorderColor=&quot;#999999&quot; BorderStyle=&quot;Solid&quot; BorderWidth=&quot;1px&quot; CellPadding=&quot;3&quot; ForeColor=&quot;Black&quot; GridLines=&quot;Vertical&quot; DataKeyNames=&quot;EmployeeID&quot; OnRowCommand=&quot;GvCustomers_RowCommand&quot;&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID=&quot;btnViewDetails&quot; runat=&quot;server&quot; Text=&quot;View&quot; CommandName=&quot;Select&quot; CommandArgument=&quot;ReadOnly&quot; /&gt; &lt;asp:LinkButton ID=&quot;btnEditDetails&quot; runat=&quot;server&quot; Text=&quot;Edit&quot; CommandName=&quot;Select&quot; CommandArgument=&quot;Edit&quot; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:BoundField DataField=&quot;EmployeeID&quot; HeaderText=&quot;EmployeeID&quot; ReadOnly=&quot;True&quot; SortExpression=&quot;EmployeeID&quot; Visible=&quot;false&quot; /&gt; &lt;asp:BoundField DataField=&quot;LastName&quot; HeaderText=&quot;LastName&quot; ReadOnly=&quot;True&quot; SortExpression=&quot;LastName&quot; /&gt; &lt;asp:BoundField DataField=&quot;FirstName&quot; HeaderText=&quot;FirstName&quot; ReadOnly=&quot;True&quot; SortExpression=&quot;FirstName&quot; /&gt; &lt;asp:BoundField DataField=&quot;Title&quot; HeaderText=&quot;Title&quot; ReadOnly=&quot;True&quot; SortExpression=&quot;Title&quot; /&gt; &lt;/Columns&gt; &lt;FooterStyle BackColor=&quot;#CCCCCC&quot; /&gt; &lt;PagerStyle BackColor=&quot;#999999&quot; ForeColor=&quot;Black&quot; HorizontalAlign=&quot;Center&quot; /&gt; &lt;SelectedRowStyle BackColor=&quot;#000099&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt; &lt;HeaderStyle BackColor=&quot;Black&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt; &lt;AlternatingRowStyle BackColor=&quot;#CCCCCC&quot; /&gt; &lt;/asp:GridView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:Panel ID=&quot;pnlPopup&quot; runat=&quot;server&quot; Width=&quot;500px&quot; Style=&quot;display: none;&quot;&gt; &lt;asp:UpdatePanel ID=&quot;updPnlCustomerDetail&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:Button ID=&quot;btnShowPopup&quot; runat=&quot;server&quot; Style=&quot;display: none&quot; /&gt; &lt;ajaxToolkit:ModalPopupExtender ID=&quot;mdlPopup&quot; runat=&quot;server&quot; TargetControlID=&quot;btnShowPopup&quot; PopupControlID=&quot;pnlPopup&quot; BackgroundCssClass=&quot;modalBackground&quot; /&gt; &lt;asp:FormView ID=&quot;fvCustomerDetail&quot; runat=&quot;server&quot; BackColor=&quot;White&quot; BorderColor=&quot;#999999&quot; DataSourceID=&quot;ldsCustomerDetail&quot; BorderStyle=&quot;Solid&quot; BorderWidth=&quot;1px&quot; CellPadding=&quot;3&quot; ForeColor=&quot;Black&quot; GridLines=&quot;Vertical&quot;&gt; &lt;FooterStyle BackColor=&quot;#CCCCCC&quot; /&gt; &lt;EditItemTemplate&gt; EmployeeID: &lt;%# Eval(&quot;EmployeeID&quot;) %&gt; &lt;asp:TextBox ID=&quot;EmployeeIDTextBox&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;EmployeeID&quot;) %&gt;' /&gt; &lt;br /&gt; LastName: &lt;%# Eval(&quot;LastName&quot;) %&gt; &lt;asp:TextBox ID=&quot;LastNameTextBox&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;LastName&quot;) %&gt;' /&gt; &lt;br /&gt; FirstName: &lt;asp:TextBox ID=&quot;FirstNameTextBox&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;FirstName&quot;) %&gt;' /&gt; &lt;br /&gt; Title: &lt;asp:TextBox ID=&quot;TitleTextBox&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Title&quot;) %&gt;' /&gt; &lt;br /&gt; Notes: &lt;asp:TextBox ID=&quot;NotesTextBox&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Notes&quot;) %&gt;' /&gt; &lt;br /&gt; &lt;asp:HiddenField ID=&quot;PhotoPathHiddenField&quot; Value='&lt;%# Bind(&quot;PhotoPath&quot;) %&gt;' runat=&quot;server&quot; /&gt; &lt;asp:Image ID=&quot;PhotoImage&quot; runat=&quot;server&quot; ImageUrl='&lt;%# Request.ApplicationPath &#43; &quot;/Photos/&quot; &#43; Eval(&quot;PhotoPath&quot;) %&gt;' /&gt;&lt;br /&gt; &lt;ajaxToolkit:AsyncFileUpload ID=&quot;AsyncFileUploadLogo&quot; runat=&quot;server&quot; UploaderStyle=&quot;Traditional&quot; OnUploadedComplete=&quot;AsyncFileUploadLogo_UploadedComplete&quot; OnClientUploadComplete=&quot;UploadComplete&quot; /&gt; &lt;br /&gt; &lt;div&gt; &lt;asp:LinkButton ID=&quot;btnSave&quot; runat=&quot;server&quot; Text=&quot;Save&quot; OnClick=&quot;BtnSave_Click&quot; CausesValidation=&quot;true&quot; /&gt; &lt;asp:LinkButton ID=&quot;btnClose&quot; runat=&quot;server&quot; Text=&quot;Close&quot; CausesValidation=&quot;false&quot; /&gt; &lt;/div&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; EmployeeID: &lt;asp:Label ID=&quot;EmployeeIDLabel&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;EmployeeID&quot;) %&gt;' /&gt; &lt;br /&gt; LastName: &lt;asp:Label ID=&quot;LastNameLabel&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;LastName&quot;) %&gt;' /&gt; &lt;br /&gt; FirstName: &lt;asp:Label ID=&quot;FirstNameLabel&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;FirstName&quot;) %&gt;' /&gt; &lt;br /&gt; Title: &lt;asp:Label ID=&quot;TitleLabel&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Title&quot;) %&gt;' /&gt; &lt;br /&gt; Notes: &lt;asp:Label ID=&quot;NotesLabel&quot; runat=&quot;server&quot; Text='&lt;%# Bind(&quot;Notes&quot;) %&gt;' /&gt; &lt;br /&gt; Photo: &lt;asp:Image ID=&quot;PhotoPathLabel&quot; runat=&quot;server&quot; ImageUrl='&lt;%# Request.ApplicationPath &#43; &quot;/Photos/&quot; &#43; Eval(&quot;PhotoPath&quot;) %&gt;' /&gt; &lt;br /&gt; &lt;div&gt; &lt;asp:LinkButton ID=&quot;btnClose&quot; runat=&quot;server&quot; Text=&quot;Close&quot; CausesValidation=&quot;false&quot; /&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;PagerStyle BackColor=&quot;#999999&quot; ForeColor=&quot;Black&quot; HorizontalAlign=&quot;Center&quot; /&gt; &lt;HeaderStyle BackColor=&quot;Black&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt; &lt;EditRowStyle BackColor=&quot;#000099&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt; &lt;/asp:FormView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre><br> <br> </p> 2009-10-29T16:15:15-04:003488519http://forums.asp.net/p/1479689/3488519.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>The following trick will help you:<br> Put the same&nbsp;AsyncFileUpload control within invisible div into&nbsp;<span style="font-size:x-small; color:#0000ff; font-family:"><span style="font-size:x-small; color:#0000ff; font-family:">&lt;</span></span><span style="font-size:x-small; color:#a31515; font-family:"><span style="font-size:x-small; color:#a31515; font-family:">ItemTemplate</span></span><span style="font-size:x-small; color:#0000ff; font-family:"><span style="font-size:x-small; color:#0000ff; font-family:">&gt;</span></span> also<br> </p> <pre class="prettyprint">&lt;EditItemTemplate&gt; ... &lt;cc1:AsyncFileUpload ID=&quot;AsyncFileUploadLogo&quot; runat=&quot;server&quot; OnUploadedComplete=&quot;AsyncFileUploadLogo_UploadedComplete&quot; /&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; ... &lt;div style=&quot;display: none;&quot;&gt; &lt;cc1:AsyncFileUpload ID=&quot;AsyncFileUploadLogo&quot; runat=&quot;server&quot; OnUploadedComplete=&quot;AsyncFileUploadLogo_UploadedComplete&quot; /&gt; &lt;/div&gt; &lt;/ItemTemplate&gt;</pre> <p><br> &nbsp;</p> 2009-11-02T04:38:11-05:003489434http://forums.asp.net/p/1479689/3489434.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>Thnaks for the suggestion. Unfortunately the problem remains. I even tried to remove the <span><span></span><span>ItemTemplate</span><span> part of the FormView, and it still doesn't work :(<br> </span></span></p> 2009-11-02T13:28:55-05:003490467http://forums.asp.net/p/1479689/3490467.aspx/1?Re+AsyncFileUpload+OnUploadedComplete+not+firingRe: AsyncFileUpload : OnUploadedComplete not firing <p>It is very strange - I have tested this solution, it works for me.&nbsp;</p> 2009-11-03T01:43:49-05:00