This is a migrated thread and some comments may be shown as answers.
Validate before upload
1 Answer 10 Views
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 27 Nov 2017, 07:33 PM

Hello!  I would like to require the user to fill in a textbox before they can select a file for upload.  Is there a javascript event that is fired on the click event of the select input? I want to prevent the file dialog from opening.  

Thank you!

 

<telerik:RadAsyncUpload ID="fuMediaUpload" runat="server" AllowedFileExtensions=".MOV,.mp4,.wmv,.avi,.mpeg,.mpg,.mp3,.aac,.m4a"
                       EnableInlineProgress="true" MaxFileInputsCount="1" ControlObjectsVisibility="None" DisableChunkUpload="false"  Skin="Bootstrap"
                       MaxFileSize="629145600" ChunkSize="10485760" OverwriteExistingFiles="true" RenderMode="Lightweight" HideFileInput="true" localization-select="Select Media File"
                       OnClientFileUploadRemoved="OnClientFileUploadRemoved" OnClientFileUploaded="OnClientFileUploaded"  EnableViewState="true"  >
                   </telerik:RadAsyncUpload>

 

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 01 Dec 2017, 11:48 AM
Hello Angie,

I am pasting the reply from the support thread here for convenience and better visibility from the community.

The OnClientFilesSelected event handler can contain the validation and if the validation failed, you can cancel the upload of the selected files. One possible issue that may arise when validating before the file is uploaded is if the textbox is cleared while the file is being uploaded.

Another possible option is to use the Manual Upload functionality and not allow the files to be uploaded before filling the textbox. The AsyncUpload - Control over Upload Process demo shows how to use the Manual Upload. 

A third possible option is to conditionally set the button as a Postback Trigger when the Textbox is not empty as described in Dynamically change the PostbackTriggers collection of the AsyncUpload.

Regards,
Peter Milchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Angie
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or