<script>
document.getElementById('Click').onclick = function (e) {
// Get the selected files
var fileDetails = document.getElementById('fileManagerId').ej2_instances[0].getSelectedFiles();
var obj = { data: fileDetails };
// Send the ajax request to the server containing selected files.
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
// Custom method the data passed
url: "/Home/Selected_Files",
data: JSON.stringify(obj),
dataType: "json",
success: function (data) {
var res = $.parseJSON(data);
$("#myform").html("<h3>Json data: <h3>" + res.fname + ", " + res.lastname)
},
error: function (xhr, err) {
}
});
}
</script> |
public IActionResult Selected_Files([FromBody] SelectedFile details)
{
// File name for selected file
var file_name = details.data[0].Name;
return View();
}
public class SelectedFile
{
public FileManagerDirectoryContent[] data { get; set; }
} |
<SfFileManager AllowDragAndDrop="true">
<FileManagerEvents ToolbarItemClicked="ToolbarItemClicked"></FileManagerEvents>
<FileManagerAjaxSettings Url="/api/Default/FileOperations"
UploadUrl="/api/Default/Upload"
DownloadUrl="/api/Default/Download"
GetImageUrl="/api/Default/GetImageUrl">
</FileManagerAjaxSettings>
<FileManagerToolbarSettings Items="@Items"></FileManagerToolbarSettings>
</SfFileManager>
@code {
public string[] Items = new string[] { "NewFolder", "Upload", "Delete", "Download", "Rename", "SortBy", "Refresh", "Selection", "View", "Details", "Custom" };
public async Task ToolbarItemClicked(Syncfusion.Blazor.FileManager.ToolbarClickEventArgs args)
{
//await Task.Run(() => { return "test"; });
var t = 0;
}
} |