Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > AsyncUpload > shorten display name?

Answered shorten display name?

Feed from this thread
  • Steven avatar

    Posted on Feb 7, 2012 (permalink)

    After selecting a file for upload, is it possible to shorten the displayed filename?

    So if a user selects veryveryverylongfilename.pdf, can I display

    veryveryverylong...  [x remove]

    but still save it as veryveryverylongfilename.pdf. I have a limited space where I have placed the control and if the filename is too long my formatting gets thrown off.



    thnx

    Reply

  • Answer Bozhidar Bozhidar admin's avatar

    Posted on Feb 7, 2012 (permalink)

    Hello Steven,

    Try the following:
    <telerik:RadAsyncUpload
        OnClientFileUploaded="fileSelected" 
        ID="RadAsyncUpload1" runat="server">
    </telerik:RadAsyncUpload>

    <script type="text/javascript">
     
        function fileSelected(sender, args) {
            var $span = $telerik.$(".ruUploadProgress", args.get_row());
            var text = $span.text();
            if (text.length>15) {
                var newString = text.substring(0, 15) + '...';
                $span.text(newString);
            }
        }
     
    </script>

     
    All the best,
    Bozhidar
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Steven avatar

    Posted on Feb 7, 2012 (permalink)

    perfect,t hanks

    Reply

  • Max avatar

    Posted on Mar 15, 2012 (permalink)

    Hello again,

    The solution is not perfect because upload progress disappears, as it is as well contained in that newly rewritten span.

    So I modified it to its true perfection :)

    function FileSelected(sender, args) {
        var spanTag = document.createElement("span");
        spanTag.className = "ruFileProgressWrap";
        var spanTagInner = document.createElement("span");
        spanTagInner.className = "ruFileProgress ruProgressStarted";
        spanTag.appendChild(spanTagInner);
         
        var $span = window.$telerik.$(".ruUploadProgress", args.get_row());
        var text = $span.text();
        if (text.length > 15) {
            var newString = text.substring(0, 15) + '...';
            $span.text(newString);
            $span.append(spanTag);
        }
    }


    Cheers.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > AsyncUpload > shorten display name?
Related resources for "shorten display name?"

ASP.NET AsyncUpload Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]