Start uploading manually more than 1 files

Last post 10-29-2012, 10:30 AM by Kenneth. 6 replies.
Sort Posts: Previous Next
  •  10-26-2012, 4:30 AM 75062

    Start uploading manually more than 1 files

    Hello!

     

    I've investigated your sample Start-uploading-manually.aspx, and have question.

    For example, i have a  two elements:

    • CutewebUI:UploadAttachments with properties MultipleFilesUpload="false" and ID="Uploader1"
    • CutewebUI:UploadAttachments with properties MultipleFilesUpload="false" and ID="Uploader2" 

    And one button Submit.

    In JavaScript code, i've seen the next construction: '<%=Uploader1.ClientID %>'

    But it works only for element with id Uploader1.

     

    How i can do the uploading from Uploader1,  and then Uploader2 on pressing button Submit only one time?

     

    Case:

    1)Press 'Submit'

    2)Expected behavior: start uploading from Uploader1, after complete uploading, start uploading from Uploader2

     

    Thanks and Regards,

    Alexey

    Filed under:
  •  10-26-2012, 7:28 AM 75066 in reply to 75062

    Re: Start uploading manually more than 1 files

    Hi AlxReiter,

     

    Please try the example below, it will work for both uploader controls.

     

    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5. <script runat="server">  
    6.   
    7.   
    8.     protected override void OnInit(EventArgs e)  
    9.     {  
    10.         base.OnInit(e);  
    11.         SubmitButton.Attributes["onclick"] = "return submitbutton_click()";  
    12.     }  
    13.   
    14. </script>  
    15. <html xmlns="http://www.w3.org/1999/xhtml">  
    16. <head id="Head1" runat="server">  
    17.     <title>Start uploading manually</title>  
    18. </head>  
    19. <body>  
    20.     <form id="form1" runat="server">  
    21.     <div class="content">  
    22.         <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1"  
    23.             InsertText="Browse Files1 (Max 1M)">  
    24.         </CuteWebUI:UploadAttachments>  
    25.         <br />  
    26.         <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader2"  
    27.             InsertText="Browse Files2 (Max 1M)">  
    28.         </CuteWebUI:UploadAttachments>  
    29.         <p>  
    30.             <asp:Button runat="server" ID="SubmitButton" Text="Submit" />  
    31.         </p>  
    32.         <script type="text/javascript">  
    33.   
    34.             function submitbutton_click() {  
    35.                 var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');  
    36.                 var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');  
    37.                 var uploadobj2 = document.getElementById('<%=Uploader2.ClientID %>');  
    38.                 if (!window.filesuploaded) {  
    39.                     if (uploadobj.getqueuecount() > 0 && uploadobj2.getqueuecount() > 0) {  
    40.   
    41.                         uploadobj.startupload();  
    42.                         uploadobj2.startupload();  
    43.                     }  
    44.                     return false;  
    45.                 }  
    46.                 window.filesuploaded = false;  
    47.                 return true;  
    48.             }  
    49.             function CuteWebUI_AjaxUploader_OnPostback() {  
    50.                 window.filesuploaded = true;  
    51.                 var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');  
    52.                 submitbutton.click();  
    53.                 return false;  
    54.             }  
    55.         </script>  
    56.     </div>  
    57.     </form>  
    58. </body>  
    59. </html>  
     

    Regards,

     

    Ken 

  •  10-26-2012, 8:35 AM 75074 in reply to 75066

    Re: Start uploading manually more than 1 files

    Ken,

     

    Thanks, it works!

  •  10-29-2012, 6:27 AM 75087 in reply to 75074

    Re: Start uploading manually more than 1 files

    As i understand, there are possibilities to implement this code in C# instead of JavaScript to start manually uploading few files? I'm right?

     

    P.S. I've met this expression first time: '<%=SubmitButton1.ClientID %>'?

    P.S.S. What is this?  I cannot find any information about it.

    P.S.S.S. Is there are any possibilities to use variable in this expression instead of number of button, for example?

     

    Thanks,

    Alexey 

  •  10-29-2012, 7:08 AM 75089 in reply to 75087

    Re: Start uploading manually more than 1 files

    Hi AlxReiter,

     

    1. The start upload manually function must start by javascript code.

     

    2. It use it get the client side id of the control. in the example, we use this client side id to get the  control instance in javascript.

     

    What variable you want to use in it? Can you explain this requirement in detail?

     

    Regards,

     

    Ken 

  •  10-29-2012, 7:42 AM 75095 in reply to 75089

    Re: Start uploading manually more than 1 files

    Ken,

     

    Lets imagine, that page has 10 elements with ids 'Uploader1', 'Uploader2' etc. User can choose the number of files for upload (from 1 to 10 and every time the number will different). When user choose number of files, not used element will hide and has and attribute Visible = true.

    For example, user should upload 5 files using 'Uploader1', 'Uploader2', 'Uploader3', 'Uploader4' and 'Uploader5'.

    I suppose, that there should be variable with number of uploader, for exampe '<%=Uploader[i].ClientID %>'to have a possibility for using every time different numbers of elements with id Uploader[i], (5, 3, 6, 7 etc).

    Maybe its too difficult :)

     

    P.S. And i have a question about using this functionality in C#.

     So, is there are possibility to use manually start uploading in this case?

    1. User choosed the number of files for upload.
    2. After he did it,wiil choose files and they will upload in database of MS SQL server after pressing button 'Submit'.

    Hope, i've explained clear :)

    Thanks and Regards,

    Alexey

  •  10-29-2012, 10:30 AM 75100 in reply to 75095

    Re: Start uploading manually more than 1 files

    Hi AlxReiter,

     

    1. Please separate  the code like below

     

    if (uploadobj.getqueuecount() > 0) {

    uploadobj.startupload();
    }
    if (uploadobj2.getqueuecount() > 0) {

    uploadobj2.startupload();
    }

     

     2. please refer to http://www.ajaxuploader.com/document/scr/html/How-to-save-uploaded-file-to-database.htm, it shows you how to save the upload file into database.

     

    Regards,

     

    Ken 

View as RSS news feed in XML