Custom Button does not fire OnClick or OnClientClick events

Last post 06-26-2009, 10:17 AM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  06-25-2009, 3:27 PM 53540

    Custom Button does not fire OnClick or OnClientClick events

    I need to create a Custom Queue Table with a Custom Button. It is a manual upload and I want the upload button to replace the Browse Button when a file is selected. However after creating a custom Browse Button I couldnt get the Browse button to hide and new upload button to appear. also tried calling basic functions nothing and events were not tirggered.
     
    Is This possible? I am trying to make the uploader match a certain style 
     
    I would like it to look like this when Selecting a File:
     
    Select File: [ Queue Table ]  [Browse Button]
     
    Then like this after selecting file:
     
    Select File: [Queue Table] [Upload Button]
     
    and like this after clicking upload:
     
    Select File: [ Progress Bar ] 
     
    Is it at all possible to control the look this much? and to force the queue table to display without files? 
  •  06-25-2009, 10:32 PM 53546 in reply to 53540

    Re: Custom Button does not fire OnClick or OnClientClick events

    Hi
     
    Please check this sample :
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
    5.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    6.   
    7. <script runat="server">  
    8.        
    9.     int uploadedcount = 0;   
    10.     protected void Uploader1_FileUploaded(object sender, UploaderEventArgs args)   
    11.     {   
    12.         uploadedcount++;   
    13.     }   
    14.   
    15.     protected void SubmitButton_Click(object sender, EventArgs e)   
    16.     {   
    17.         servermsg.Text = "You have uploaded " + uploadedcount + " files";   
    18.     }   
    19. </script>  
    20.   
    21. <html xmlns="http://www.w3.org/1999/xhtml">  
    22. <head runat="server">  
    23.     <title>Sample</title>  
    24.   
    25.     <script type="text/javascript">  
    26.     var submitbtnid="<%=SubmitButton.ClientID %>";   
    27.     var uploaderid="<%=Uploader1.ClientID %>";   
    28.     var ispostback=false;   
    29.     var isuploading=false;   
    30.     function CuteWebUI_AjaxUploader_OnQueueUI(list)   
    31.     {   
    32.         var uploader=this;   
    33.         var submitbtn=document.getElementById(submitbtnid);   
    34.         if(list.length==0)   
    35.         {   
    36.             uploader.internalobject.insertBtn.style.display="";   
    37.             submitbtn.style.display="none";   
    38.         }   
    39.         else   
    40.         {   
    41.             uploader.internalobject.insertBtn.style.display="none";   
    42.             if(isuploading)   
    43.                 submitbtn.style.display="none";   
    44.             else   
    45.                 submitbtn.style.display="";   
    46.         }   
    47.     }   
    48.        
    49.     function Submit_ClientClick()   
    50.     {   
    51.         if(ispostback)   
    52.             return true;   
    53.         var uploader=document.getElementById(uploaderid);   
    54.         var submitbtn=document.getElementById(submitbtnid);   
    55.         uploader.startupload();   
    56.         submitbtn.style.display="none";   
    57.         return false;   
    58.     }   
    59.     function CuteWebUI_AjaxUploader_OnPostback()   
    60.     {   
    61.         isuploading=false;   
    62.         var submitbtn=document.getElementById(submitbtnid);   
    63.         ispostback=true;   
    64.         submitbtn.click();   
    65.         return false;   
    66.     }   
    67.     function CuteWebUI_AjaxUploader_OnStart()   
    68.     {   
    69.         isuploading=true;   
    70.     }   
    71.     function CuteWebUI_AjaxUploader_OnStop()   
    72.     {   
    73.         isuploading=false;   
    74.     }   
    75.     </script>  
    76.   
    77. </head>  
    78. <body>  
    79.     <form id="form1" runat="server">  
    80.         <div>  
    81.             Select Files   
    82.             <hr />  
    83.             <CuteWebUI:Uploader runat="server" ID="Uploader1" ManualStartUpload="true" MultipleFilesUpload="true"  
    84.                 InsertText="Browse" OnFileUploaded="Uploader1_FileUploaded" />  
    85.             <hr />  
    86.             <asp:Button runat="server" ID="SubmitButton" Text="Submit" Style="display: none;" OnClientClick="return Submit_ClientClick()" OnClick="SubmitButton_Click" />  
    87.         </div>  
    88.         <asp:Label runat="server" ID="servermsg" ForeColor="red" Font-Bold="true" />  
    89.     </form>  
    90. </body>  
    91. </html>  
     
     
    Regards,
    Terry
     
     
  •  06-26-2009, 9:42 AM 53559 in reply to 53546

    Re: Custom Button does not fire OnClick or OnClientClick events

    this code was helpful in getting the original browse button to display and disappear based on whether or not a file is selected but this code does not render out the queue table regardless of whether there are files in it or not. I want the Queue table to be persistent and always present on the page.
     
    Ideally I would like to have the empty queue table row display a custom message.
     
    Is it possible to use the queue table in this form? 
     
  •  06-26-2009, 10:17 AM 53562 in reply to 53559

    Re: Custom Button does not fire OnClick or OnClientClick events

    Hi,
     
    You can draw your custom queue table , please check this sample:
     
     
    Regards,
    Terry
     
View as RSS news feed in XML