Validate page before Select files

2 posts, 0 answers
  1. Angie
    Angie avatar
    120 posts
    Member since:
    Jan 2008

    Posted 05 Mar 2013 Link to this post

    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;
  2. Plamen
    Plamen avatar
    3080 posts

    Posted 08 Mar 2013 Link to this post

    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) {
            <telerik:RadAsyncUpload runat="server" ID="RadAsyncuplaod1">

    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,
    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.
Back to Top