I looked everywhere to get a selected item from a file explorer in C#, but nothing worked.
I need only the name and the extension to update my database, is that possible?
1 Answer, 1 is accepted
0
Vessy
Telerik team
answered on 19 Jan 2021, 06:48 PM
Hi Hamza,
The file-selecting functionality of RadFileExplorer is implemented on the client-side and such is available only on the client. You can access the selected file with the following logic:
var selectedFile = $find("RadFileExplorer1").get_selectedItem();
var fileName = selectedFile.get_name();
var ext = selectedFile.get_extension()
If you need to access this information on the server, you could store the selected file name into a hidden field and access its value later on the server. For example, you can store it in the OnClientItemSelected event-handler:
<telerik:RadFileExplorerID="RadFileExplorer1"runat="server"OnClientItemSelected="onItemSelected"><ConfigurationViewPaths="~/"DeletePaths="~/"UploadPaths="~/" /></telerik:RadFileExplorer><asp:HiddenFieldID="SelectedFileFld"runat="server" /><script>functiononItemSelected(fileExplorer, args) {
var selectedItem = args.get_item();
var fileName = selectedItem.get_name();
$get("SelectedFileFld").value = fileName;
//access SelectedFileFld.Value on the server when you need it
}
</script>
Regards,
Vessy
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.