No items required

Last post 03-13-2012, 4:12 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  01-21-2012, 7:52 AM 72782

    No items required

    Hi,
     
    I have an uploader on a page with other data.
    Uploading items is optional. But if no items are selected my page won't postback (and the rest of the data cannot be saved).
    Where do I set that uploading of images is optional in the ajaxuploader?
     
    this is my code:
     
    1. <script type="text/javascript">  
    2.   
    3.             function submitbutton_click() {  
    4.                 var submitbutton = document.getElementById('<%=btnSave.ClientID %>');  
    5.                 var uploadimg = document.getElementById('<%=uplImages.ClientID %>');  
    6.                 var uploadobj = document.getElementById('<%=uplAttach.ClientID %>');  
    7.                 if (!window.filesuploaded) {  
    8.                     if (uploadobj.getqueuecount() > 0) {  
    9.                         uploadobj.startupload();  
    10.                     }  
    11.                     if (uploadimg.getqueuecount() > 0) {  
    12.                         uploadimg.startupload();  
    13.                     }  
    14.                     return false;  
    15.                 }  
    16.                 window.filesuploaded = false;  
    17.                 return true;  
    18.             }  
    19.   
    20.             function CuteWebUI_AjaxUploader_OnPostback() {  
    21.                 window.filesuploaded = true;  
    22.                 var submitbutton = document.getElementById('<%=btnSave.ClientID %>');  
    23.                 submitbutton.click();  
    24.                 return false;  
    25.             }  
    26.         </script>  
    Any help would be appreciated
     
    thx 
  •  03-13-2012, 4:12 PM 73434 in reply to 72782

    Re: No items required

    Hi dbots,
     
    Please try the example below, it will submit the forum whatever the uploader control has items or not. The upload files will be the optional.
     
    <%@ 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 id="Head1" 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 as RSS news feed in XML