Fire asp.net codebehind after upload

Last post 09-08-2009, 12:07 PM by calmusz. 4 replies.
Sort Posts: Previous Next
  •  08-31-2009, 1:57 PM 55212

    Fire asp.net codebehind after upload

    Hello, I'm new the the Ajax Uploader, and just wondering how to auto fire a code behind function AFTER all the selected files are upload? 
    I basiclly want to run a process on all the uploaded photos once the upload completes.
  •  08-31-2009, 9:52 PM 55219 in reply to 55212

    Re: Fire asp.net codebehind after upload

    Hi,
     
    After uploader uploaded all files , it will run
     
    client side javascript :
     
     
    2 - submit the form
     
    server side :
     
    3 - fire FileUploaded for each file
     
    4 - fire UploadCompleted for all files.
     
    Regards,
    Terry
     
  •  09-03-2009, 3:02 PM 55363 in reply to 55219

    Re: Fire asp.net codebehind after upload

    Hello, thanks for the help, but could you tell me how to fire the server side UploadCompleted?
    Here is what I have:
    My Control on the page:
     <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" InsertText="Click to select Files" OnUploadCompleted="Uploader_UploadCompleted" > </CuteWebUI:UploadAttachments>
     
    My function on server side
    void Uploader_UploadCompleted(object sender, UploaderEventArgs args)
            {
                doSomthingWithFiles();
            }
     
    I get a "does not contain a definition for 'Uploader_UploadCompleted'" error message.
    Thanks for the help
  •  09-06-2009, 11:11 PM 55403 in reply to 55363

    Re: Fire asp.net codebehind after upload

    Hi calmusz,
     
    Try this example
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    4.   
    5. <script runat="server">   
    6.       
    7.     int count;   
    8.     protected void Uploader1_FileUploaded(object sender, UploaderEventArgs args)   
    9.     {   
    10.         count++;   
    11.         if (count == int.Parse(Hidden1.Value))   
    12.         {   
    13.             Complete();   
    14.         }   
    15.     }   
    16.     void Complete()   
    17.     {   
    18.         //will fire after uploader complete   
    19.         ClientScript.RegisterClientScriptBlock(this.GetType(), "showcount""<script>alert('" + Hidden1.Value + "')</" + "script>");   
    20.     }   
    21. </script>   
    22.   
    23. <html xmlns="http://www.w3.org/1999/xhtml">   
    24. <head runat="server">   
    25.     <title>Untitled Page</title>   
    26. </head>   
    27. <body>   
    28.     <form id="form1" runat="server">   
    29.         <CuteWebUI:Uploader ID="Uploader1" runat="server" OnFileUploaded="Uploader1_FileUploaded"  
    30.             MultipleFilesUpload="true">   
    31.         </CuteWebUI:Uploader>   
    32.         <input id="Hidden1" type="hidden" runat="server" />   
    33.         <asp:Label ID="label1" runat="server"></asp:Label>   
    34.     </form>   
    35. </body>   
    36. </html>   
    37.   
    38. <script type="text/javascript">   
    39. function CuteWebUI_AjaxUploader_OnSelect(files)   
    40.   
    41. {   
    42. var hidden1=document.getElementById('<%= Hidden1.ClientID%>');   
    43. hidden1.value=files.length;   
    44.     
    45. }   
    46.   
    47. </script>  
    Regards,
     
    Ken
  •  09-08-2009, 12:07 PM 55445 in reply to 55403

    Re: Fire asp.net codebehind after upload

    Hey thanks for the example.  I will try it out and let you know how it works.
    Thanks again
View as RSS news feed in XML