Limiting the number of files.

2 posts, 1 answers
  1. Berkman
    Berkman avatar
    23 posts
    Member since:
    Feb 2013

    Posted 16 Apr 2013 Link to this post

    Hi,

    The RadUpload control I am using is intended to upload only three files at a time. If the user select more than three files and try to upload, I want to show an alert. How?

    Thankyou,
    Berk
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Apr 2013 Link to this post

    Hi,

    You can use JavaScript to check the selected number of files against a constant. Please have a look at the following code.

    JavaScript:
    <script type="text/javascript">
        function OnClientFilesSelected(sender, eventArgs) {
            if (eventArgs.get_count() > 3) {
                // eventArgs.set_cancel('true') cancels the upload and no files are sent to the server
                eventArgs.set_cancel(true);
                // alert the user that they have selected too many files
                alert("Select a maximum of 3 files");
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top