Re: execute code when no items to be uploaded

  •  02-29-2012, 7:59 AM

    Re: execute code when no items to be uploaded

    Hi dbots,
     
    Please try the example page below, the submit button will fire every time.
     
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <!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 SubmitButton_Click(object sender, EventArgs e)
        {
            label1.Text = "submit button clicked!";
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Start uploading manually</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:Label ID="label1" runat="server"></asp:Label><br />
            <CuteWebUI:UploadAttachments ID="Uploader1" runat="server" ManualStartUpload="true">
            </CuteWebUI:UploadAttachments>
            <br />
            <br />
            <asp:Button runat="server" ID="SubmitButton" OnClientClick="return submitbutton_click()"
                Text="Submit" OnClick="SubmitButton_Click" /><br />
            <script type="text/javascript">
       function submitbutton_click() {
           var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
           var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');
           if (uploadobj.getqueuecount() == 0) {
               submitbutton.click();
           } else {
               if (!window.filesuploaded) {
                   if (uploadobj.getqueuecount() > 0) {
                       uploadobj.startupload();
                   }
                   return false;
               }
           }
           window.filesuploaded = false;
           return true;
       }
       function CuteWebUI_AjaxUploader_OnPostback() {
           window.filesuploaded = true;
           var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
           submitbutton.click();
           return false;
       }
            </script>
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken 
View Complete Thread