I use a FormView as a detailview of a GridView to show and edit data.
The FormView is in an UpdatePanel and shown with a ModalPoupController on an event of the GridView.
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.
The OnClientUploadComplete event is fired but the OnUploadedComplete event is never fired.
I have almost the same page with a FormView in InsertMode and it works great, but this FormView is not in an UpdatePanel.
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 ?
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
I did not decide anything , it's just that nothing happens. Putting a breakpoint at the beginning of the function called by
OnUploadedComplete shows that this function is never called.
Is your code similar to mine? Please test my code firstly.
Or please post your code snippet here to help us reproduce it.
Best regards,
Zhi-Qiang Ni
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
This is the problem in my case. Can you point me in the right direction?
The AsyncFileUpload i placed in a UpdatePanel with Updatemode="Always". It is not a nested UpdatePanel.
This is how the code-behind looks:
Protected Sub File1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles File1.UploadedComplete
lblStatus.Text = "Done!"
End Sub
The thing is, lblStatus does not show the new value "Done!". I can put a breakpoint in the above code and it works as usual.
What can be the problem?
Your changes the UpdatePanel in a temporary iframe used for async uploading.
Do the following:
Protected Sub File1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles File1.UploadedComplete
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "reply", "top.$get('" & lblStatus.ClientID & "').innerHTML= 'Done!';", True)
End Sub
Don't forget to mark this post as "answer", if it helped you...
sovitec
Member
3 Points
16 Posts
AsyncFileUpload : OnUploadedComplete not firing
Oct 09, 2009 01:31 PM|LINK
Hi,
I use a FormView as a detailview of a GridView to show and edit data.
The FormView is in an UpdatePanel and shown with a ModalPoupController on an event of the GridView.
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.
The OnClientUploadComplete event is fired but the OnUploadedComplete event is never fired.
I have almost the same page with a FormView in InsertMode and it works great, but this FormView is not in an UpdatePanel.
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 ?
Thanks for your help.
asyncfileUpload issue
Zhi-Qiang Ni...
All-Star
33491 Points
2952 Posts
Microsoft
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 14, 2009 01:35 PM|LINK
Hi sovitec,
To display the image after the UploadedComplete event is fired, we need to register a script which is used to set the image’s src property.
Please test my sample here. The UploadedComplete event can be fired whether the AsyncFileUpload control inside an UpdatePanel or not.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestUploadedCompleteEvent.aspx.cs" Inherits="SoluTest_AsyncFileUpload.TestUploadedCompleteEvent" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script runat="server"> protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true); string savePath = MapPath("~/Uploads/" + System.IO.Path.GetFileName(e.filename)); AsyncFileUpload1.SaveAs(savePath); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "image", "top.$get(\"" + Image1.ClientID + "\").src = 'Uploads/" + System.IO.Path.GetFileName(e.filename) + "';", true); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> Please upload a image:<br /> <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" /> <br /> <br /> Here is your image:<br /> <asp:Label runat="server" Text=" " ID="uploadResult" /><br /> <asp:Image ID="Image1" runat="server" /></ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>Have it helped?
Best regards,
Zhi-Qiang Ni
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
sovitec
Member
3 Points
16 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 14, 2009 03:50 PM|LINK
Thanks for your answer. Unfortunately this is the OnUploadedComplete that is not fired, OnClientUploadCompleteworks in every case.
obout_teo
Contributor
2418 Points
398 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 03:17 AM|LINK
There is no UploadComplete event. There are OnUploadedComplete and OnClientUploadComplete events.
What from them does not work?
sovitec
Member
3 Points
16 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 08:18 AM|LINK
Ooops, sorry, OnUploadedComplete does not work, OnClientUploadComplete that I've mistakenly called UploadComplete if firing correctly.
Thanks for your help
obout_teo
Contributor
2418 Points
398 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 08:39 AM|LINK
Why have you decided that OnUploadedComplete does not work?
It doesn't change the UpdatePanel ?
sovitec
Member
3 Points
16 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 09:38 AM|LINK
I did not decide anything
, it's just that nothing happens. Putting a breakpoint at the beginning of the function called by
OnUploadedComplete shows that this function is never called.
Zhi-Qiang Ni...
All-Star
33491 Points
2952 Posts
Microsoft
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 09:43 AM|LINK
Hi sovitec,
Is your code similar to mine? Please test my code firstly.
Or please post your code snippet here to help us reproduce it.
Best regards,
Zhi-Qiang Ni
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
Robotnic
Member
4 Points
2 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 15, 2009 01:11 PM|LINK
This is the problem in my case. Can you point me in the right direction?
The AsyncFileUpload i placed in a UpdatePanel with Updatemode="Always". It is not a nested UpdatePanel.
This is how the code-behind looks:
The thing is, lblStatus does not show the new value "Done!". I can put a breakpoint in the above code and it works as usual.
What can be the problem?
obout_teo
Contributor
2418 Points
398 Posts
Re: AsyncFileUpload : OnUploadedComplete not firing
Oct 16, 2009 01:18 AM|LINK
Your changes the UpdatePanel in a temporary iframe used for async uploading.
Do the following:
Protected Sub File1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles File1.UploadedComplete ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "reply", "top.$get('" & lblStatus.ClientID & "').innerHTML= 'Done!';", True) End Sub