This is a migrated thread and some comments may be shown as answers.

getfilename and fill textbox on file uploaded

2 Answers 366 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
TelDev
Top achievements
Rank 1
TelDev asked on 04 Dec 2013, 01:29 PM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Dec 2013, 02:50 AM
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.
0
Sean
Top achievements
Rank 1
answered on 28 Nov 2018, 03:02 PM

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

Tags
AsyncUpload
Asked by
TelDev
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sean
Top achievements
Rank 1
Share this question
or