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

Validate page before Select files

1 Answer 55 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 05 Mar 2013, 10:23 PM
Hello.  I'm wondering if I can set up the RadAsyncUpload control to allow the page to be validated for required fields before the user can select files for upload.

Currently it's set up so I'm using the OnClientFileSelected event to try to catch the validation.  It fails validation, but the Async upload is still performed.   I'd prefer to perform validation when the "SELECT" button is clicked, and prevent opening of the file dialog window altogether.

Is there a way to do this?  Thanks.
<telerik:RadAsyncUpload ID="RadUpload" ControlObjectsVisibility=None runat="server" OnClientFilesUploaded="OnClientFilesUploaded" OnClientFilesSelected="OnClientFilesSelected"
HideFileInput="true" Skin="Hay" MultipleFileSelection="Automatic" AllowedFileExtensions=".jpeg,.jpg,.png,.gif" />

function OnClientFilesSelected(sender)
{
if ( !Validate() ) return false;
}

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 08 Mar 2013, 01:43 PM
Hi Angie,

 

Such validation can be achieved with jQuery as in the code below:

<script type="text/javascript">
            Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable = function () { return false; }
 
            function pageLoad() {
                var $ = $telerik.$;
                if (Validate) {
                $(".ruFileInput").click(function myfunction(e) {
                    e.stopPropagation();
                    e.preventDefault();
                });
                }
            }
 
        </script>
    <div>
        <telerik:RadAsyncUpload runat="server" ID="RadAsyncuplaod1">
        </telerik:RadAsyncUpload>

Please have in mind that such validation can not be achieved when RadAsyncUpload uses Silverlight upload module so you will have to add the following as well if you want it to work properly in all browsers.

Hope this will be helpful.

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
AsyncUpload
Asked by
Angie
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or