limit file number demo can't work when using personal defined insert button

Last post 01-09-2012, 5:46 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  01-07-2012, 7:01 AM 72541

    limit file number demo can't work when using personal defined insert button

    I'm success testing demo "multiple-files-upload-control-file-number", but when i define  "InsertButtonID='Uploader1Insert'", it always enable the upload button, below is my code, i test visible and enable attribute both in InsertButton and personal defined div Uploader1Insert, hope could get reply soon, thanks a lot
     
                base.OnPreRender(e);
                if (UploadAttachments1.Items.Count>= 3)
                {
                    Uploader1Insert.Visible = false;
                    UploadAttachments1.InsertButton.Enabled = false;
                }
                else
                {
                    Uploader1Insert.Visible = true;
                    UploadAttachments1.InsertButton.Enabled = true;
                }
     
  •  01-09-2012, 5:46 AM 72556 in reply to 72541

    Re: limit file number demo can't work when using personal defined insert button

    Hi steveyuan,
     
    If you use property InsertButtonID, please set this control directly
     
    <%@ 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 override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (GetVisibleItemCount() >= 3)
            {
                button1.Enabled = false;
            }
            else
            {
                button1.Enabled = true;
            }
        }
        int GetVisibleItemCount()
        {
            int count = 0;
            foreach (AttachmentItem item in uploader1.Items)
            {
                if (item.Visible)
                    count++;
            }
            return count;
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CuteWebUI:UploadAttachments ID="uploader1" runat="server" InsertButtonID="button1">
                </CuteWebUI:UploadAttachments>
                <asp:Button ID="button1" runat="server" Text="upload files" />
            </div>
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken 
View as RSS news feed in XML