Manual upload with visible="false"

Last post 11-15-2012, 2:01 PM by Kenneth. 7 replies.
Sort Posts: Previous Next
  •  11-12-2012, 7:34 AM 75205

    Manual upload with visible="false"

    Hello

     

    I have script below for uploading files. But, if i will set to element "fileinput1" attribute Visible="false", uploading doesn't work for any element with attribute Visibility="true".

     

    1. function submitbutton_click() {  
    2.   
    3.             var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');  
    4.   
    5.             var fileInputs = ["<%=fileinput1.ClientID%>""<%=fileinput2.ClientID%>""<%=fileinput3.ClientID%>"];  
    6.   
    7.             if (!window.filesuploaded)  
    8.             {  
    9.                 for(var i=0; i<3; i++) {  
    10.   
    11.                     var uploadobj = document.getElementById(fileInputs[i]);  
    12.                     if (uploadobj.getqueuecount() > 0)  
    13.                     {  
    14.                         uploadobj.startupload();  
    15.                     }  
    16.                 }  
    17.                 return false;  
    18.             }  
    19.               
    20.             window.filesuploaded = false;  
    21.             return true;  

  •  11-12-2012, 8:29 AM 75209 in reply to 75205

    Re: Manual upload with visible="false"

    Hi AlxReiter,

     

    Can you show me the full example page code? So I can test it on my end.

     

    Regards,

     

    Ken 

  •  11-13-2012, 2:44 AM 75233 in reply to 75209

    Re: Manual upload with visible="false"

    1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_myStartUploadingManually.aspx.cs" Inherits="AJAXUploader_new_version_basic_samples._myStartUploadingManually" %> 
    2. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %> 
    3.  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    5.  
    6. <html xmlns="http://www.w3.org/1999/xhtml"> 
    7. <head id="Head1" runat="server"> 
    8.     <title>Start uploading manually</title> 
    9.     <link rel="stylesheet" href="demo.css" type="text/css" /> 
    10.     <script type="text/javascript" src="jquery-1.8.2.min.js"></script> 
    11.     <script type="text/javascript"> 
    12.  
    13.         function CuteWebUI_AjaxUploader_OnSelect(files) { 
    14.             for (var i = 0; i < files.length; i++) { 
    15.                 if (files[i].FileSize > 2097152) 
    16.                     alert("File to large!"); 
    17.                 files[i].Cancel(); 
    18.              } 
    19.          } 
    20.  
    21.         function submitbutton_click() { 
    22.  
    23.             var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>'); 
    24.  
    25.             var fileInputs = ["<%=fileinput1.ClientID%>", "<%=fileinput2.ClientID%>", "<%=fileinput3.ClientID%>"]; 
    26.  
    27.             if (!window.filesuploaded) { 
    28.                 for(var i=0; i<3; i++) { 
    29.  
    30.                     var uploadobj = document.getElementById(fileInputs[i]); 
    31.                     if (uploadobj.getqueuecount() > 0) { 
    32.                         uploadobj.startupload(); 
    33.                     } 
    34.                 } 
    35.                 return false; 
    36.             } 
    37.              
    38.             window.filesuploaded = false
    39.             return true; 
    40.         } 
    41.          
    42.         </script>   
    43. </head> 
    44. <body> 
    45.     <form id="form1" runat="server"> 
    46.         <asp:ScriptManager ID="Scriptmanager1" runat="server"></asp:ScriptManager> 
    47.             <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    48.                 <ContentTemplate> 
    49.                     <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
    50.                          
    51.                         <tr valign="middle"> 
    52.                             <td class='standardText'><asp:Label Visible="false" ID="label1" runat="server">First file for upload</asp:Label></td> 
    53.                             <td class='standardText'><CuteWebUI:Uploader runat="server"  
    54.                                     ManualStartUpload="true" ID="fileinput1" 
    55.                                 InsertText="Browse Files1" onfileuploaded="fileinput_FileUploaded"   
    56.                                     MultipleFilesUpload="false" ValidateOption-MaxSizeKB="2097152"></CuteWebUI:Uploader></td> 
    57.                         </tr> 
    58.                          
    59.                         <tr valign="middle"> 
    60.                             <td class='standardText'><asp:Label Visible="true" ID="label2" runat="server">Second file for upload</asp:Label></td> 
    61.                             <td class='standardText'><CuteWebUI:Uploader runat="server" ManualStartUpload="true" ID="fileinput2"   
    62.                                 InsertText="Browse Files2" onfileuploaded="fileinput_FileUploaded" MultipleFilesUpload="false" ValidateOption-MaxSizeKB="2097152"></CuteWebUI:Uploader></td> 
    63.                         </tr> 
    64.                          
    65.                         <tr valign="middle"> 
    66.                             <td class='standardText'><asp:Label Visible="true" ID="label3" runat="server">Last file for upload</asp:Label></td> 
    67.                             <td class='standardText'><CuteWebUI:Uploader runat="server" ManualStartUpload="true" ID="fileinput3"   
    68.                                 InsertText="Browse Files3" onfileuploaded="fileinput_FileUploaded" MultipleFilesUpload="false" ValidateOption-MaxSizeKB="2097152"></CuteWebUI:Uploader></td> 
    69.                         </tr> 
    70.                          
    71.                         <caption> 
    72.                             <p> 
    73.                                 <asp:Button ID="SubmitButton" runat="server" Text="Submit"  
    74.                                     OnClientClick="return submitbutton_click()" /> 
    75.                             </p> 
    76.                         </caption> 
    77.                     </table> 
    78.                 </ContentTemplate> 
    79.         </asp:UpdatePanel> 
    80.     </form> 
    81. </body> 
    82. </html> 
  •  11-13-2012, 7:16 AM 75237 in reply to 75233

    Re: Manual upload with visible="false"

    Hi AlxReiter,

     

    I have tried your example page, and I still not understand what is the issue you mean, can you show me in detail?

     

    1.  Click on the upload button nothing happen?

     

    2. Can select the file for upload, but the uploader does not shows the file you selected?

     

    3. Allow to select the file for upload, after click on the submit button, the upload has not start?

     

    4. The upload start correct, but nothting upload to the server?

     

    Regards,

     

    Ken 

  •  11-14-2012, 5:35 AM 75250 in reply to 75237

    Re: Manual upload with visible="false"

    Ken,

     

    There is description of a case:

    1. On this page, i have 3 Uploader element.

    2. First element has an attribute Visible="False".

    3. Browse files for upload using second and than third element.

    4. Press button Submit.

    5. Uploading doesn't start.

     

    This case don't work for any element (for example, 1st element has attribute Visible="True", 2nd elemtnt has attribute Visible="False"). 

     

    But, if you  change attribute Visible to "True" for all elements, the upload running successfully.

     

  •  11-14-2012, 6:40 AM 75251 in reply to 75250

    Re: Manual upload with visible="false"

    Hi AlxReiter ,

     

    I am not sure what you mean the "element" , is a <div>/<asp:panel>/<p> or others?

     

    In the example your provided, I only find the visible property in the <asp:lable> target, is this the element you mean?

     

    Can you provide the example page which I can run on my end and reproduce this issue? Please remove the unnecessary code and resource.

     

    Is your site online? If so, can you send me your uploader page url? So I can test it directly.

     

    Regards,

     

    Ken

     

  •  11-15-2012, 8:14 AM 75265 in reply to 75251

    Re: Manual upload with visible="false"

    Ken,

     I apologize, that i don't clearly explained what i mean.

     

    Here is the code.

     

    There are 3 elements of  CuteWebUI:Uploader with ID "fileinput1", "fileinput2" and "fileinput3".

     

    Element with ID "fileinput1" has an attributeVisible="False". Other elements has an attribute Visible="True".

     

    If you run this code, and try to upload files using elements with ID "fileinput2" or (and) with ID "fileinput3", and press Submit button, uploads will not execute.

     

     But, if you change attribute of "fileinput1" from Visible="False" to "True", and try this case again, you will see that upload works.

     

     Also, you can try to do this case:

    1. For element "fileinput1" set attribute Visible to"True"

    2. For element "fileinput2" set attribute Visible to"False"

    3. For element "fileinput3" set attribute Visible to"True"

    4. Run page, choose file in "fileinput1" element for upload, and choose file in "fileinput3" for upload.

    5. Press Submit button to start upload.

    5. The result: file from "fileinput1" will uploaded, file from "fileinput3" will not uploaded.

     

    Code of page:

    1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_myStartUploadingManually.aspx.cs" Inherits="AJAXUploader_new_version_basic_samples._myStartUploadingManually" %> 
    2. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %> 
    3.  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    5.  
    6. <html xmlns="http://www.w3.org/1999/xhtml"> 
    7. <head id="Head1" runat="server"> 
    8.     <title>Start uploading manually</title> 
    9.     <link rel="stylesheet" href="demo.css" type="text/css" />  
    10.     <script type="text/javascript" src="jquery-1.8.2.min.js"></script>  
    11.     <script type="text/javascript"> 
    12.          
    13.         function submitbutton_click() { 
    14.  
    15.             var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>'); 
    16.  
    17.             var fileInputs = ["<%=fileinput1.ClientID%>",
    18.                               "<%=fileinput2.ClientID%>",
    19.                               "<%=fileinput3.ClientID%>"]; 
    20.  
    21.             if (!window.filesuploaded) { 
    22.                 for(var i=0; i<3; i++) { 
    23.  
    24.                     var uploadobj = document.getElementById(fileInputs[i]); 
    25.                     if (uploadobj.getqueuecount() > 0) { 
    26.                         uploadobj.startupload(); 
    27.                     } 
    28.                 } 
    29.                 return false; 
    30.             } 
    31.              
    32.             window.filesuploaded = false
    33.             return true; 
    34.         } 
    35.          
    36.    </script>   
    37. </head> 
    38. <body> 
    39.     <form id="form1" runat="server">  
    40.         <asp:ScriptManager ID="Scriptmanager1" runat="server"></asp:ScriptManager> 
    41.         <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
    42.             <ContentTemplate> 
    43.                 <table border="0" cellpadding="0" cellspacing="0" width="100%">  
    44.                     <tr valign="middle">  
    45.                         <td class='standardText'><asp:Label Visible="true" ID="label1" runat="server">First file for upload</asp:Label></td>  
    46.                         <td class='standardText'>   
    47.                             <CuteWebUI:Uploader  
    48.                                 runat="server" 
    49.                                 ManualStartUpload="true" 
    50.                                 ID="fileinput1" 
    51.                                 InsertText="Browse Files1" 
    52.                                 onfileuploaded="fileinput_FileUploaded" 
    53.                                 MultipleFilesUpload="false" 
    54.                                 Visible="False"> 
    55.                             </CuteWebUI:Uploader> 
    56.                         </td> 
    57.                     </tr> 
    58.                     <tr valign="middle">  
    59.                         <td class='standardText'><asp:Label Visible="true" ID="label2" runat="server">Second file for upload</asp:Label></td>  
    60.                         <td class='standardText'> 
    61.                             <CuteWebUI:Uploader  
    62.                                 runat="server"  
    63.                                 ManualStartUpload="true"  
    64.                                 ID="fileinput2"   
    65.                                 InsertText="Browse Files2"  
    66.                                 onfileuploaded="fileinput_FileUploaded"  
    67.                                 MultipleFilesUpload="false"  
    68.                                 Visible="True"> 
    69.                             </CuteWebUI:Uploader> 
    70.                         </td> 
    71.                     </tr> 
    72.                     <tr valign="middle">  
    73.                         <td class='standardText'><asp:Label Visible="true" ID="label3" runat="server">Last file for upload</asp:Label></td>  
    74.                         <td class='standardText'> 
    75.                             <CuteWebUI:Uploader  
    76.                                 runat="server"  
    77.                                 ManualStartUpload="true"  
    78.                                 ID="fileinput3"   
    79.                                 InsertText="Browse Files3"  
    80.                                 onfileuploaded="fileinput_FileUploaded"  
    81.                                 MultipleFilesUpload="false"  
    82.                                 ValidateOption-MaxSizeKB="2097152"  
    83.                                 Visible="True"> 
    84.                             </CuteWebUI:Uploader> 
    85.                         </td> 
    86.                     </tr> 
    87.  
    88.                     <caption> 
    89.                         <p> 
    90.                             <asp:Button  
    91.                                 ID="SubmitButton"  
    92.                                 runat="server"  
    93.                                 Text="Submit"  
    94.                                 OnClientClick="return submitbutton_click()" /> 
    95.                         </p> 
    96.                     </caption> 
    97.                 </table> 
    98.             </ContentTemplate> 
    99.         </asp:UpdatePanel> 
    100.     </form> 
    101. </body> 
    102. </html> 
     Thanks,

    Alexey

  •  11-15-2012, 2:01 PM 75266 in reply to 75265

    Re: Manual upload with visible="false"

    Hi,

     

    You need to check the uploader instance is available before you use "startupload()". Try the example below

    I just added the section below for your code.

     

    if (uploadobj) {}

    1. <%@ Page Language="C#" AutoEventWireup="true" %> 
    2.  
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %> 
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    5. <html xmlns="http://www.w3.org/1999/xhtml"
    6. <head id="Head1" runat="server"
    7.     <title>Start uploading manually</title> 
    8.     <script type="text/javascript"
    9.  
    10.         function submitbutton_click() { 
    11.  
    12.             var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>'); 
    13.  
    14.             var fileInputs = ["<%=fileinput1.ClientID%>"
    15.                               "<%=fileinput2.ClientID%>"
    16.                               "<%=fileinput3.ClientID%>"]; 
    17.  
    18.             if (!window.filesuploaded) { 
    19.                 for (var i = 0; i < 3; i++) { 
    20.  
    21.                     var uploadobj = document.getElementById(fileInputs[i]); 
    22.                     if (uploadobj) { 
    23.                         if (uploadobj.getqueuecount() > 0) { 
    24.                             uploadobj.startupload(); 
    25.                         } 
    26.                     } 
    27.  
    28.                 } 
    29.                 return false
    30.             } 
    31.  
    32.             window.filesuploaded = false
    33.             return true
    34.         }  
    35.           
    36.     </script> 
    37. </head> 
    38. <body> 
    39.     <form id="form1" runat="server"
    40.     <table border="0" cellpadding="0" cellspacing="0" width="100%"
    41.         <tr valign="middle"
    42.             <td class='standardText'
    43.                 <asp:Label Visible="true" ID="label1" runat="server">First file for upload</asp:Label> 
    44.             </td> 
    45.             <td class='standardText'
    46.                 <CuteWebUI:Uploader runat="server" ManualStartUpload="true" ID="fileinput1" InsertText="Browse Files1" 
    47.                     MultipleFilesUpload="true" Visible="False"
    48.                 </CuteWebUI:Uploader> 
    49.             </td> 
    50.         </tr> 
    51.         <tr valign="middle"
    52.             <td class='standardText'
    53.                 <asp:Label Visible="true" ID="label2" runat="server">Second file for upload</asp:Label> 
    54.             </td> 
    55.             <td class='standardText'
    56.                 <CuteWebUI:Uploader runat="server" ManualStartUpload="true" ID="fileinput2" InsertText="Browse Files2" 
    57.                     MultipleFilesUpload="true" Visible="True"
    58.                 </CuteWebUI:Uploader> 
    59.             </td> 
    60.         </tr> 
    61.         <tr valign="middle"
    62.             <td class='standardText'
    63.                 <asp:Label Visible="true" ID="label3" runat="server">Last file for upload</asp:Label> 
    64.             </td> 
    65.             <td class='standardText'
    66.                 <CuteWebUI:Uploader runat="server" ManualStartUpload="true" ID="fileinput3" InsertText="Browse Files3" 
    67.                     MultipleFilesUpload="true" ValidateOption-MaxSizeKB="2097152" Visible="True"
    68.                 </CuteWebUI:Uploader> 
    69.             </td> 
    70.         </tr> 
    71.         <caption> 
    72.             <p> 
    73.                 <asp:Button ID="SubmitButton" runat="server" Text="Submit" OnClientClick="return submitbutton_click()" /> 
    74.             </p> 
    75.         </caption> 
    76.     </table> 
    77.     </form> 
    78. </body> 
    79. </html> 

     

    Regards,

     

    Ken

     

View as RSS news feed in XML