Get File Extention and Size direct after selection of the file!!!

Thread is closed for posting
3 posts, 0 answers
  1. Asa'ad
    Asa'ad avatar
    77 posts
    Member since:
    May 2011

    Posted 14 Sep 2011 Link to this post

    Hi All,

    I have a form with a RadGird that load a saved images files from the database....
    all is ok...
    The grid has the option of adding new one and edit the existing....

    I have added TemplateColumns for the Image column, that has Edit and Insert Item templates....

    In those template i added the RadUpload Control, to allow the user to select the file he wants to save to the database...

    the grid and insert and the edit function all works ok....

    But i need to show the the extention and size of the selected file to be saved before it is saved to the database and show them in read only textboxes also shown in the edit/insert form....

    I can find this upload control in the grid itemcreated event and i added the an event handler of this upload control to handle the FileExists event and i added the function to be called when this event fires BUT this function nevers called!!!!

    Here is my code in the grid item created event

    MyUploadControl.FileExists += new 
    and this is the function defined to handle this event

    Protected void myFunction(Object sender, 
    Telerik.Web.UI.Upload.UploadedFileEventArgs e){  someLabel.Text = 
    "my function is called";
    my idea is to get the size and exetenstion of the selecetd file within this function and show them in the corresponding controls....

    But this function never calls....

    I don't know what i am missing????

    Any help will be great....

  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 14 Sep 2011 Link to this post

    Hello Asa'ad,

    The FileExists event is never raised because it is only called when the file could not be saved to a folder. You can use the ValidatingFile event as it is always raised when a file is uploaded.

    I hope that helps.
  3. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 16 Sep 2011 Link to this post

    Hello Kevin,

    To get the file's size, the file should be uploaded to the server(RadUpload is using a standard input type='file' control and it is not possible to get the file's size on the client-side). It is possible to validate file's extension on the client-side. Please review the following help article.

    In case you want to check the file's size and extension on the client, please use RadAsyncUpload control. Probably the following demos will be helpful for you - Validation, RadAsyncUpload in RadGrid.

    Peter Filipov
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Back to Top