Upload button Enable

Last post 08-16-2012, 1:55 AM by kalees1980. 3 replies.
Sort Posts: Previous Next
  •  08-13-2012, 6:56 AM 74414

    Upload button Enable

    Hi,
     
    I have 2 upload controls upload1 and upload2 in my page. I want to disable the upload2 button when the user uploading file from upload1 controls and end of the uploading i have to enable the upload1. the same way i want vice versa.
     
    I want to achive the process flow like
     
    by simple my problem,
     
    I do not want user to click 2 upload process in the sametime.
     
    I tried this also

    Under filevalidating event of Uploader

    Uploader2.InsertButton.Enabled = false;

    But button is not disabled; But the same code works on page load.
    Thanks
    Kalees
  •  08-14-2012, 7:55 AM 74419 in reply to 74414

    Re: Upload button Enable

    Hi kalees1980,
     
    Please try the example below, it shows you how to achieve your requirement.
     
    1. <%@ Page Language="C#"  %>  
    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. </head>  
    8. <body>  
    9.     <form id="Form1" runat="server">  
    10.         <CuteWebUI:UploadAttachments ID="uploader1" runat="server" InsertText="uploader1">  
    11.         </CuteWebUI:UploadAttachments>  
    12.          <CuteWebUI:UploadAttachments ID="uploader2" runat="server" InsertText="uploader2">  
    13.         </CuteWebUI:UploadAttachments>  
    14.     </form>  
    15. </body>  
    16. </html>  
    17.   
    18. <script>  
    19. var uploader1=document.getElementById("<%= uploader1.ClientID %>");  
    20. var uploader2=document.getElementById("<%= uploader2.ClientID %>");  
    21. function CuteWebUI_AjaxUploader_OnStart()  
    22. {  
    23.     var hidden=this;  
    24.     if(hidden.id=="uploader1")  
    25.     {  
    26.         //if upload1 uploading,disable uploader2  
    27.         uploader2.internalobject.insertBtn.disabled="disabled";  
    28.     }  
    29.     else  
    30.     {  
    31.         //if upload2 uploading,disable uploader2  
    32.         uploader1.internalobject.insertBtn.disabled="disabled";  
    33.     }  
    34. }  
    35. </script>  
    Regards,
     
    Ken 
     
  •  08-15-2012, 11:14 PM 74428 in reply to 74414

    Re: Upload button Enable

    Hi Kim,
     
    It is working after i did some minor changes.
     
    During cancel all update button click, then i need to enable the control
     
    i tried with
    CuteWebUI_AjaxUploader_OnStop { var hidden = this; 
    if (hidden.id == "MainContent_SubModelFilesUploader")
    {graphicsuploader2.internalobject.insertBtn.disabled = "enabled";}else {uploader1.internalobject.insertBtn.disabled = "enabled";}
     
    But it is not working.
     
    Thanks in aDVANCE
     
    Kalees
  •  08-16-2012, 1:55 AM 74430 in reply to 74414

    Re: Upload button Enable

    Hi,
     
    Finally i achieved by this way;
     The solution is.
              <script type="text/javascript">
                  var ClickedUploderId = "";
                  function CuteWebUI_AjaxUploader_OnStart() {
                              var uploader1 = document.getElementById("<%= uploader1.ClientID %>");
                              var uploader2 = document.getElementById("<%= uploader2.ClientID %>");
                              var hidden = this;
                              ClickedUploderId = "";
                                  if (hidden.id == "uploader1") {
                                    //if upload1 uploading,disable upload2
                                    uploader2.internalobject.insertBtn.disabled = "disabled";
                                    ClickedUploderId = "upload1";
                                  }
                                  else {
                                    //if upload2 uploading,disable upload1
                                    uploader1.internalobject.insertBtn.disabled = "disabled";
                                    ClickedUploderId = "upload2";
                                  }
                              }
                              function CuteWebUI_AjaxUploader_OnStop() { //  "Cancel All Update" call
                              var uploader1 = document.getElementById("<%= uploader1.ClientID %>");
                              var uploader2 = document.getElementById("<%= uploader2.ClientID %>");   
                                if (ClickedUploderId == "upload1") {
                                        uploader2.internalobject.insertBtn.disabled = "";
                                      }
                                    else
                                    { uploader1.internalobject.insertBtn.disabled = ""; }
                              }
                  </script>
     
    At last,
    protected void uploader1_UploadCompleted (object sender, CuteWebUI.UploaderEventArgs[] args){     Uploader2.InsertButton.Enabled = true;}
     
    Thanks for your help
     
    My one question is,
    var uploader1 = document.getElementById("<%= uploader1.ClientID %>");
     if i declare it above the OnStart method, then i got the runtime javascript errror that Uploader2 is undefined;
    But i moved to inside the method block it is working.
     
    Regards
    Kalees
View as RSS news feed in XML