getfilename and fill textbox on file uploaded

3 posts, 0 answers
  1. TelDev
    TelDev avatar
    32 posts
    Member since:
    Dec 2009

    Posted 04 Dec 2013 Link to this post

    HI Telerik,

    I am using radasyncupload control and I want to fill a textbox with the file name after the file uploaded is complete.

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

    Posted 04 Dec 2013 Link to this post

    Hi TelDev,

    Please try the following code snippet to fill the RadTextBox value with uploaded filename.

    ASPX:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnClientFileUploaded="OnClientFilesUploaded1">
    </telerik:RadAsyncUpload>
    <asp:Label ID="Label1" runat="server" Text="Uploaded FileNames">
    </asp:Label>
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Width="70%">
    </telerik:RadTextBox>

    JavaScript:
    <script type="text/javascript">
        var str = "";
        function OnClientFilesUploaded1(sender, args) {
            var text = $find("<%=RadTextBox1.ClientID %>");
            str = str + args.get_fileName() + ",";
            text.set_value(str);
        }
    </script>

    Thanks,
    Shinu.
  3. Sean
    Sean avatar
    21 posts
    Member since:
    Feb 2018

    Posted 28 Nov 2018 Link to this post

    Hello, 

    I have similar question/problem. I wanted same behavior which I was able to achieve so now i have something like this:

    <style type="text/css">
      .InlineBlockClass { display: inline-block; }
      .ruFileWrap { display: inline !important;}
      .ruFileInput {width: 55px; height: 10px; }
    </style>
     
    <div>
      <telerik:RadTextBox ID="FileName" runat="server" CssClass="InlineBlockClass" width="80%" />
      <telerikRadAsyncUpload ID="FileUploader" runat="server" CssClass="InlineBlockClass" width="15%" HideFileInput="true" AutoAddFileInputs="false" MultipleFileSelection="Disabled"/>
    </div>

    Problem (also partially observed on this demo https://demos.telerik.com/aspnet-ajax/asyncupload/examples/overview/defaultcs.aspx ): i have this area of .ruFileInput which is invisible yet goes on either to left or right. (you can inspect demo page and dig in on uploadcontrol) in my case if i click on invisible area it open file selection window as if i am clicking on select button. So i reduced the height and width to 0 of .ruFileInput which means that click Select button doesnt do anything. If i make .ruFileInput exact size of button then it sits right behind it and then clicking button opens that browse file. Even after that there seems to be something lingering on side causing my panel to expand horizontally and giving scroll bars. I was wondering if you can help me with this. 

    Moreover, RadAsyncUpload have a textbox like control next to Select button by default. Is there anyway to use that as a text box so that when i select a file, select button disables, file name shows up in the textbox, little green/red circle above text box with name and progress and if user wants to give it a different name they can in the textbox. I will have a upload/Save button on panel so that on button's click i can change file name before uploading maybe? Appreciate your help!

    Thank you,

    Sean

Back to Top