Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center
in Search

How to stop autopostback after selecting multiple files

Last post 09-06-2012, 12:30 AM by ChetanRajakumar. 4 replies.
Sort Posts: Previous Next
  •  09-03-2012, 4:25 AM 74541

    How to stop autopostback after selecting multiple files

    Hi,

     

    I have below code,

    <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertButtonID="TestButton"

    MultipleFilesUpload="true" OnFileValidating="Find_MultiDocs">

    <ValidateOption MaxSizeKB="10240" />

    </CuteWebUI:Uploader>

    <cc:SubmitButton ID="TestButton" runat="server" Text="Select Multiple Documents"/>

     

    This is for selcting multiple files and triggering an event 'OnFileValidating' and In the 'Find_MultiDocs' method i am reading all the selected document's name.

    By getting all the selected dodcument's name, one-by-one i am checking whether the document's name exists in db or not ; if the document exist in db, i need to display existing documents in dataGrid by populating it to Datasource.

     

    I am able to populate the datasource and get all the data to datatable to display it in grid.

    But after getting all the data, the control is moving to OnInit method where the dataGrid is getting refreshed.

    Since the dataGrid is refreshed, dataGrid data is not displayed in the page.

    I suspect this is because page is getting refreshed(autopostback) after 'OnFileValididating'. Please some one help me out to solve this.

    Thanks in advance.

     

    Regards,

    Chetan. 

  •  09-03-2012, 8:25 AM 74544 in reply to 74541

    Re: How to stop autopostback after selecting multiple files

    Hi ChetanRajakumar,

     

    Please try the example below. In the example below, I check the file name which with string 'a', and add it for the datalist control. You can use the same code to check the file name from your database.

     

    1. <%@ Page Language="C#" AutoEventWireup="True" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <%@ Import Namespace="System.Data" %>  
    5. <html>  
    6.   
    7. <script runat="server">  
    8.   
    9.     ICollection CreateDataSource(ArrayList files)  
    10.     {  
    11.         DataTable dt = new DataTable();  
    12.         DataRow dr;  
    13.         dt.Columns.Add(new DataColumn("FileName"typeof(String)));  
    14.         for (int i = 0; i < files.Count; i++)  
    15.         {  
    16.             dr = dt.NewRow();  
    17.             dr[0] = files[i].ToString();  
    18.             dt.Rows.Add(dr);  
    19.         }  
    20.         DataView dv = new DataView(dt);  
    21.         return dv;  
    22.     }  
    23.     protected void uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)  
    24.     {  
    25.   
    26.         ArrayList files = new ArrayList();  
    27.         for (int i = 0; i < args.Length; i++)  
    28.         {  
    29.             //check the exists file names here  
    30.             if (args[i].FileName.IndexOf("a") != -1)  
    31.             {  
    32.                 //Compared with the database file name  
    33.                 //if file exists, add into the ArrayList  
    34.                 files.Add(args[i].FileName);  
    35.             }  
    36.   
    37.         }  
    38.         //generate the data source  
    39.         ItemsList.DataSource = CreateDataSource(files);  
    40.         ItemsList.DataBind();  
    41.     }  
    42.   
    43.   
    44. </script>  
    45.   
    46. <body>  
    47.     <form id="Form1" runat="server">  
    48.         <CuteWebUI:Uploader ID="uploader1" runat="server" MultipleFilesUpload="true" OnUploadCompleted="uploader1_UploadCompleted" InsertText="select multiple files">  
    49.         </CuteWebUI:Uploader>  
    50.         <asp:DataList ID="ItemsList" RepeatDirection="Vertical" RepeatLayout="Table" runat="server">  
    51.             <ItemTemplate>  
    52.                 file name:  
    53.                 <%# DataBinder.Eval(Container.DataItem, "FileName")%>  
    54.             </ItemTemplate>  
    55.         </asp:DataList>  
    56.     </form>  
    57. </body>  
    58. </html>  
     

     

    Regards,

     

    Ken 

  •  09-05-2012, 12:33 AM 74573 in reply to 74544

    Re: How to stop autopostback after selecting multiple files

    Hi Ken,

     

    Many Thanks for the code, it made my work easy.

     

    One more question; After doing multiSelect of files and click on open, we will be seeing the list of files which is getting uploaded with cancel buttons., can we hide this??

    That is, after Multi-Select of files and click on Open button, uploading should be done at background.User must not see the uploading and user should not be able to cancel the files which he has given for uploading.

     

     

    Thanks and Regards,

    Chetan. 

  •  09-05-2012, 7:26 AM 74575 in reply to 74541

    Re: How to stop autopostback after selecting multiple files

    Hi,

     

    The example below shows you how to hide the "cancel" and "cancel all" button.

     

    1. <%@ Page Language="C#" Title="Customize the queue UI" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">  
    5. <html xmlns="http://www.w3.org/1999/xhtml">  
    6. <head id="Head1" runat="server">  
    7.     <style>  
    8. .AjaxUploaderCancelAllButton {  
    9.  display: none !important;  
    10. }  
    11. </style>  
    12. </head>  
    13. <body>  
    14.     <form id="Form1" runat="server">  
    15.         <CuteWebUI:UploadAttachments ID="uploader1" runat="server" CancelButtonID="myCancel">  
    16.         </CuteWebUI:UploadAttachments>  
    17.         <input type="button" id="myCancel" style="visibility: hidden" />  
    18.     </form>  
    19. </body>  
    20. </html>  
     

    1. Set property  "CancelButtonID" and hide the control what you set for will hide the "cancel" button.

     

    2. The style setting below use to hide the "cancel all" button.

     

    <style>
    .AjaxUploaderCancelAllButton {
     display: none !important;
    }
    </style>
     

    Regards,

     

    Ken 

  •  09-06-2012, 12:30 AM 74579 in reply to 74575

    Re: How to stop autopostback after selecting multiple files

    Hi Ken,

     

    Perfect, Thanks a lot.

    The below code worked fine as per my requirement:

    <

    CuteWebUI:Uploader runat="server" ID="Uploader1" InsertButtonID="FindButton"

    MultipleFilesUpload="true" OnUploadCompleted="Find_MultiDocs" CancelButtonID="CancelButton"

    NumFilesShowQueueUI="9999" UploadProcessingMsg="" UploadingMsg="" ShowProgressInfo="false"

    ShowProgressBar="false">

    <ValidateOption MaxSizeKB="10240" />

    </CuteWebUI:Uploader>

    <cc:SubmitButton ID="FindButton" runat="server" Text="Find Multiple Documents"/>

    <input type="button" id="CancelButton" style="visibilityhidden" />

     

    Thanks once again Ken.

     

    Regards,

    Chetan. 

     

     

View as RSS news feed in XML
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.