Support forums
in

Clearing Ajax Uploader items

Last post 06-28-2011, 8:47 AM by Eric. 3 replies.
Sort Posts: Previous Next
  •  06-27-2011, 2:55 PM 68178

    Clearing Ajax Uploader items

    Hello.  After I successfully upload files using the AJAX Uploader control, I would like to clear the items from showing in the control, is there a way to do that?  I am using uploader.cancelall(); before the files are uploaded to clear the selected items, however, after the files are uploaded, I would like to clear the files uploaded from showing in the selected files box.  I have a limit of 3 files per upload, so I would like to reset the number of files to 0 so that the user can upload more files?  Where is the best place to achieve this and what is the best to do it?  For example, after the upload happens on the server side, I was expecting to be able to call uploader.items.clear but it does not appear that there is such a function.  Thoughts/suggestions?
     
    Thanks. 
  •  06-27-2011, 9:05 PM 68185 in reply to 68178

    Re: Clearing Ajax Uploader items

    Hi mchamo,
     
    Please try the example below
     
    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.     protected void button1_Click(object sender, EventArgs e)  
    8.     {  
    9.         for (int i = Attachment1.Items.Count - 1; i >= 0; i--)  
    10.         {  
    11.             Attachment1.Items[i].Remove();  
    12.         }  
    13.     }  
    14. </script>  
    15.   
    16. <html xmlns="http://www.w3.org/1999/xhtml">  
    17. <head id="Head1" runat="server">  
    18.     <title>example</title>  
    19. </head>  
    20. <body>  
    21.     <form id="Form1" runat="server">  
    22.         <CuteWebUI:UploadAttachments ID="Attachment1" runat="server">  
    23.         </CuteWebUI:UploadAttachments>  
    24.         <asp:Button ID="button1" runat="server" Text="Clean items" OnClick="button1_Click" />  
    25.     </form>  
    26. </body>  
    27. </html> 
    Regards,
     
    ken
  •  06-28-2011, 7:27 AM 68195 in reply to 68185

    Re: Clearing Ajax Uploader items

    Thanks.  So based on your example. we have to remove the files one at a time?  There is no one call to remove all the files? 
     
    Kenneth:
    Hi mchamo,
     
    Please try the example below
     
    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.     protected void button1_Click(object sender, EventArgs e)  
    8.     {  
    9.         for (int i = Attachment1.Items.Count - 1; i >= 0; i--)  
    10.         {  
    11.             Attachment1.Items[i].Remove();  
    12.         }  
    13.     }  
    14. </script>  
    15.   
    16. <html xmlns="http://www.w3.org/1999/xhtml">  
    17. <head id="Head1" runat="server">  
    18.     <title>example</title>  
    19. </head>  
    20. <body>  
    21.     <form id="Form1" runat="server">  
    22.         <CuteWebUI:UploadAttachments ID="Attachment1" runat="server">  
    23.         </CuteWebUI:UploadAttachments>  
    24.         <asp:Button ID="button1" runat="server" Text="Clean items" OnClick="button1_Click" />  
    25.     </form>  
    26. </body>  
    27. </html> 
    Regards,
     
    ken
  •  06-28-2011, 8:47 AM 68198 in reply to 68195

    Re: Clearing Ajax Uploader items

    Hi mchamo,
     
    You can try the following code:
     
    <%@ Page Language="C#" %>   
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    <script runat="server">
        protected void button1_Click(object sender, EventArgs e) 
        {  
                       Attachment1.DeleteAllAttachments(); 
        } 
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head id="Head1" runat="server"> 
        <title>example</title> 
    </head> 
    <body> 
        <form id="Form1" runat="server"> 
            <CuteWebUI:UploadAttachments ID="Attachment1" runat="server"> 
            </CuteWebUI:UploadAttachments> 
            <asp:Button ID="button1" runat="server" Text="Clean items" OnClick="button1_Click" /> 
        </form> 
    </body> 
    </html>
     
    Thanks for asking
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems