This is a migrated thread and some comments may be shown as answers.

Automatic create a blank entry

2 Answers 47 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 12 Feb 2009, 07:17 PM
Adding the code there doesn't do anything.

If the user used [Select] for a file, automatically generate another blank entry below (avoid having them click on [Add])

OnClientFileSelected="checkExtension"

      function checkExtension(radUpload, eventArgs) [
          radUpload.addFileInput;
          var input = eventArgs.get_fileInputField();
          if (!radUpload.isExtensionValid(input.value)) [
              var inputs = radUpload.getFileInputs();
              for (i = 0; i < inputs.length; i++) [
                  if (inputs[i] == input) [
                      alert(input.value + " does not have a valid extension.");
                      radUpload.clearFileInputAt(i);
                      break;
                  ]
              ]

          ]
      ]

2 Answers, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 13 Feb 2009, 03:05 PM
Hi Lenny_shp,

JavaScript uses curly braces { } for code blocks instead of [] brackets. Here is the correct, working variant of your function:

function checkExtension(radUpload, eventArgs) {
            radUpload.addFileInput();
            var input = eventArgs.get_fileInputField();
            if (!radUpload.isExtensionValid(input.value)) {
                var inputs = radUpload.getFileInputs();
                for (i = 0; i < inputs.length; i++) {
                    if (inputs[i] == input) {
                        alert(input.value + " does not have a valid extension.");
                        radUpload.clearFileInputAt(i);
                        break;
                    }
                }
            }
        }

Regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Lenny_shp
Top achievements
Rank 2
answered on 17 Feb 2009, 03:11 PM
Thanks, my code does have [ ], not sure why it displayed [ ] when was posted/pasted.
The problem was that I had this:
radUpload.addFileInput;
instead of the working version of:
radUpload.addFileInput();
Tags
Upload (Obsolete)
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
Lenny_shp
Top achievements
Rank 2
Share this question
or