Get size in client validation failed

4 posts, 0 answers
  1. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 10 Sep 2013 Link to this post

    Hello support,

    Is there any way I can get the file size in client validation failed client event?

    Thanks
    Tia
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Sep 2013 Link to this post

    Hi Tia,

    With Upload Modules other than File Api, it is not possible to get the uploaded file size in the OnClientValidationFailed event. Suppose you are using the File Api Upload Module, then you can get the file size using jQuery as follows.

    JavaScript:
    <script type="text/javascript">
        function OnClientValidationFailed(sender, args) {
            var jQueryRowObject = $telerik.$(args.get_row());
            alert(jQueryRowObject.find("input")[0].files[0].size);
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 10 Sep 2013 Link to this post

    I can disable the other modules. Thanks for answering me shinu. I need another help. I am using asyncupload to upload large files. How can I display the progress like 10%, 50% completed ? I dont need any separate controls such as progressarea.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Sep 2013 Link to this post

    Hi Tia,

    You can use the OnClientProgressUpdating client event of the RadAsyncUpload to achieve your requirement. Please have a look at the sample code I tried which works fine at my end.

    ASPX:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnClientProgressUpdating="OnClientProgressUpdating"
        OnClientFilesUploaded="OnClientFilesUploaded" TargetFolder="~/User/Uploads/" MaxFileSize="579371152"
        MultipleFileSelection="Automatic" UploadedFilesRendering="BelowFileInput">
    </telerik:RadAsyncUpload>
    <br />
    <asp:Label ID="Label1" runat="server">
    </asp:Label>

    JavaScript:
    <script type="text/javascript">
        function OnClientFilesUploaded(sender, args) {
            document.getElementById("Label1").innerHTML = "Uploads Completed";
     
        }
        function OnClientProgressUpdating(sender, args) {
            var data = args.get_data();
            var percents = data.percent;
            document.getElementById("Label1").innerHTML = "Completed : " + percents.toString() + "%";
        }
    </script>

    Thanks,
    Shinu.
Back to Top