How can i change the MaxFileLimit by Javascript in runtaime.

Last post 01-04-2012, 2:40 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  01-04-2012, 6:40 AM 72500

    How can i change the MaxFileLimit by Javascript in runtaime.

    I have a two type of document upload scheme. for a perticular  type i don't allow the user to upload more than one file,but still in second type user can. all the control are in one form and no post back untill submit button. so i need ur help man urgently.
    Filed under:
  •  01-04-2012, 2:40 PM 72505 in reply to 72500

    Re: How can i change the MaxFileLimit by Javascript in runtaime.

    Hi ksanjay,
     
    The example below shows you how to handle the max file limit by javascript. In the example below I set the max to 2.
     
    <%@ Page Language="C#" Title="Customize the queue UI" %>
    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <script runat="server">
        protected void uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)
        {
            count.Value = uploader1.Items.Count.ToString();
        }
        protected void uploader1_AttachmentRemoveClicked(object sender, AttachmentItemEventArgs args)
        {
            count.Value = (uploader1.Items.Count - 1).ToString();
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <form id="Form1" runat="server">
            <div>
                <CuteWebUI:UploadAttachments runat="server" ID="uploader1" OnUploadCompleted="uploader1_UploadCompleted"
                    OnAttachmentRemoveClicked="uploader1_AttachmentRemoveClicked">
                </CuteWebUI:UploadAttachments>
                <asp:HiddenField ID="count" runat="server" />
            </div>
        </form>
    </body>
    </html>
    <script>
    var max=2;
    var count=document.getElementById("<%= count.ClientID %>").value;
    function CuteWebUI_AjaxUploader_OnSelect(files)
    {
       
        count=parseInt(count)+files.length;
     
        if(files.length>max||count>max)
        {
              alert("max files limit is 2");
            return false;
        }
    }
    </script>
     
    Regards,
     
    Ken 
View as RSS news feed in XML