Validate Extensions for Each File Input Client-side

Thread is closed for posting
3 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 24 Apr 2007 Link to this post

    Requirements

    RadControls version

    Telerik.Web.UI 2007.3.12.18+
    or
    RadUpload v2.1.1+

    .NET version

    NET 2.x/3.x

    Visual Studio version

    2005/2008

    programming language

    JavaScript, C#

    browser support

    all browsers supported by r.a.d.controls


     

    PROJECT DESCRIPTION
    This project demonstrates a way to validate extensions client-side for each file input in RadUpload and place an * sign next to those file inputs where the selected files have forbidden extensions.

    We use RadUpload's OnClientAdded event to add a hidden span with the * sign right next to every file input in RadUpload.

    IMPORTANT NOTE: In order to ensure the proper operation of the event handler in all browsers you must declare the function before the RadUpload declaration!

    The validation is done by integrating the RadUpload with a CustomValidator which will prevent the page from submitting when there are selected files with invalid extensions.

    IMPORTANT NOTE: The ControlToValidate property of the CustomValidator must not be set!

    In the custom validator's ClientValidationFunction we iterate through all file inputs and check whether the selected file has a in/valid extension and show/hide the * sign for the given file input row correspondingly. According to the result of the validation we set the IsValid property of the event arguments.

    For versions Q1 2011 SP2(2011.1.519.35) + , please use the updated archive.

  2. CC37D7E5-289E-466F-8DCB-A5039E8A09C0
    CC37D7E5-289E-466F-8DCB-A5039E8A09C0 avatar
    49 posts
    Member since:
    Nov 2007

    Posted 11 Feb 2008 Link to this post

    Hello Sir,

    i tried to use the same code you attached in order to create a Hidden field for each upload.
    i use this hidden field later on to fill it with data in javascript, i managed to do that perfectly. but the problem is that i cannot use the data in server side!!!!

    can you lead me please?

  3. E9CFDAAB-168D-40FF-82EE-B5BB43C9B7FA
    E9CFDAAB-168D-40FF-82EE-B5BB43C9B7FA avatar
    636 posts
    Member since:
    Sep 2012

    Posted 11 Feb 2008 Link to this post

    Hi,

    Thank you for contacting us.

    There should not be a problem to use server-side the value of the hidden field which you have created via javascript. This problem does not directly refer to RadUpload control. You should simply submit the form and find the hidden field in the post collection server-side.  For your convenience I have attached a sample page which demonstrates how to add additional hidden fields to RadUpload and how to find the value of the first hidden field server-side.

    In case you experience difficulties in achieving your scenario, please, send us a simple running application which demonstrates what you want to achieve and what are the problems you encounter and we will do our best to help you.

    Best regards,
    Sophy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.