Example of Flat Data in ASP.NET MVC File Manager Control
This sample demonstrates flat data rendering of the File Manager component. The File Manager uses a flat data object as list of objects for rendering, eliminating the need to define the AjaxSettings url.
<h3>Flat data</h3>
<p>The files are a flat list in the page: every item names the folder it is in by its id. New folder, rename, delete, cut, copy and paste change the list in the browser; nothing goes to a server. Read the list back to save it your own way.</p>
@{
var stamp = new DateTime(2026, 9, 14, 10, 30, 0);
var files = new List<UiFileSystemItem>
{
new UiFileSystemItem { Id = "0", Name = "Files", DateModified = stamp },
new UiFileSystemItem { Id = "1", ParentId = "0", Name = "Documents", DateModified = stamp },
new UiFileSystemItem { Id = "2", ParentId = "1", Name = "Plans", DateModified = stamp },
new UiFileSystemItem { Id = "3", ParentId = "2", Name = "Roadmap.txt", IsFile = true, Size = 2380, DateModified = stamp.AddDays(-3) },
new UiFileSystemItem { Id = "4", ParentId = "1", Name = "Report.docx", IsFile = true, Size = 24576, DateModified = stamp.AddDays(-1) },
new UiFileSystemItem { Id = "5", ParentId = "0", Name = "Pictures", DateModified = stamp },
new UiFileSystemItem { Id = "6", ParentId = "5", Name = "Team outing.png", IsFile = true, Size = 182044, DateModified = stamp.AddDays(-20) },
new UiFileSystemItem { Id = "7", ParentId = "0", Name = "Readme.txt", IsFile = true, Size = 1200, DateModified = stamp.AddDays(-30) }
};
}
<div class="nav-actions">
<button type="button" data-filemanager-flat>Read the list back</button>
</div>
@Html.UiFileManager(new UiFileManagerOptions
{
Id = "fmFlat",
FileSystemData = files,
Height = "420px",
OnSelect = "NavigationFileManager.onSelect",
OnSuccess = "NavigationFileManager.onSuccess",
OnFailure = "NavigationFileManager.onFailure"
})
@section scripts {
<script>
(function (window, document) {
'use strict';
function log(message) {
if (window.NavigationSampleLog) { window.NavigationSampleLog(message); }
}
// Never forward server errors, filenames, paths or file contents to the shared log.
window.NavigationFileManager = {
onSelect: function (items) { log('Selection count: ' + items.length); },
onSuccess: function () { log('Operation completed.'); },
onFailure: function () { log('Operation failed; details omitted.'); },
cancelOpen: function () { log('File opening cancelled.'); return false; },
// Custom thumbnails: PDF files get an icon of the page's own (the class is styled by the sample).
onFileLoad: function (args) {
if (args.module !== 'NavigationPane' && args.item.type === '.pdf') { args.element.classList.add('fm-custom-pdf'); }
}
};
document.querySelectorAll('.navigation-sample [data-filemanager-api]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('navigationFileManager');
if (!control) { log('Control not ready.'); return; }
var operation = this.getAttribute('data-filemanager-api');
var pending;
if (operation === 'folder') { pending = control.openFolder('/Documents/Reports'); }
if (operation === 'refresh') { pending = control.refresh(); }
if (operation === 'inspect') {
log('Folder available: ' + Boolean(control.getPath()) + '; selection count: ' + control.getSelected().length);
}
if (operation === 'view') {
control.setView(control.getView() === 'details' ? 'largeicons' : 'details');
log('View changed.');
}
if (pending && pending.catch) { pending.catch(function () { log('API request failed; details omitted.'); }); }
});
});
document.querySelectorAll('.navigation-sample [data-filemanager-flat]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('fmFlat');
var data = control && control.getFileSystemData();
log(data ? 'The list holds ' + data.length + ' items.' : 'Control not ready.');
});
});
document.querySelectorAll('.navigation-sample [data-filemanager-virtual]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('fmVirtual');
if (control) { control.setView(control.getView() === 'details' ? 'largeicons' : 'details'); log('View changed.'); }
});
});
var picker = document.getElementById('fileManagerTheme');
if (picker) {
picker.addEventListener('change', function () {
var control = window.Lumen.get('navigationFileManager');
if (control) { control.setTheme(this.value); log('Instance theme changed.'); }
});
}
})(window, document);
</script>
}
<div class="navigation-sample">
<style>
.navigation-sample .nav-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.navigation-sample .nav-row > * { flex: 1 1 280px; min-width: 0; }
.navigation-sample .nav-caption { margin: 16px 0 6px; font-weight: 600; }
.navigation-sample .nav-frame { height: 260px; border: 1px solid var(--ui-border); border-radius: 4px; }
.navigation-sample .nav-main { height: 100%; box-sizing: border-box; padding: 12px 16px; overflow: auto; }
.navigation-sample .nav-side { padding: 12px; }
.navigation-sample .nav-files { display: flex; flex-wrap: wrap; gap: 12px; }
.navigation-sample .nav-file { width: 150px; padding: 12px; border: 1px solid var(--ui-border); cursor: context-menu; }
.navigation-sample .nav-file:focus-visible { outline: 2px solid var(--ui-accent); }
.navigation-sample .nav-file small { display: block; }
.navigation-sample .ui-tab-panel { padding: 12px 4px; }
.navigation-sample .nav-slide { height: 100%; display: flex; align-items: center; justify-content: center; color: white; font-size: 28px; }
.navigation-sample .nav-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.navigation-sample .nav-log { font-family: monospace; font-size: 12px; max-height: 200px; overflow-y: auto; border: 1px solid var(--ui-border); padding: 8px 24px; }
.navigation-sample .nav-icon { width: 16px; height: 16px; background: currentColor; clip-path: polygon(50% 0, 100% 40%, 85% 40%, 85% 100%, 15% 100%, 15% 40%, 0 40%); }
</style>
<p role="note">Use synthetic demo files only. Creating, renaming, moving, copying, uploading or deleting changes files on disk in the demo's restricted App_Data folder. Never upload personal, client or confidential files. Uploads are limited to 2 MB. Read-only previews enforce changes being refused on the server.</p>
<p>These demo actions are not a production authorisation model: the responsible security reviewer must validate host authentication, authorisation and filesystem permissions before adoption.</p>
<h3>Flat data</h3>
<p>The files are a flat list in the page: every item names the folder it is in by its id. New folder, rename, delete, cut, copy and paste change the list in the browser; nothing goes to a server. Read the list back to save it your own way.</p>
@{
var stamp = new DateTime(2026, 9, 14, 10, 30, 0);
var files = new List<UiFileSystemItem>
{
new UiFileSystemItem { Id = "0", Name = "Files", DateModified = stamp },
new UiFileSystemItem { Id = "1", ParentId = "0", Name = "Documents", DateModified = stamp },
new UiFileSystemItem { Id = "2", ParentId = "1", Name = "Plans", DateModified = stamp },
new UiFileSystemItem { Id = "3", ParentId = "2", Name = "Roadmap.txt", IsFile = true, Size = 2380, DateModified = stamp.AddDays(-3) },
new UiFileSystemItem { Id = "4", ParentId = "1", Name = "Report.docx", IsFile = true, Size = 24576, DateModified = stamp.AddDays(-1) },
new UiFileSystemItem { Id = "5", ParentId = "0", Name = "Pictures", DateModified = stamp },
new UiFileSystemItem { Id = "6", ParentId = "5", Name = "Team outing.png", IsFile = true, Size = 182044, DateModified = stamp.AddDays(-20) },
new UiFileSystemItem { Id = "7", ParentId = "0", Name = "Readme.txt", IsFile = true, Size = 1200, DateModified = stamp.AddDays(-30) }
};
}
<div class="nav-actions">
<button type="button" data-filemanager-flat>Read the list back</button>
</div>
@Html.UiFileManager(new UiFileManagerOptions
{
Id = "fmFlat",
FileSystemData = files,
Height = "420px",
OnSelect = "NavigationFileManager.onSelect",
OnSuccess = "NavigationFileManager.onSuccess",
OnFailure = "NavigationFileManager.onFailure"
})
</div>
@section below {
<div class="navigation-sample">
<h3>Event log</h3>
<ul id="navigationEventLog" class="nav-log" aria-live="polite"></ul>
<script>
window.NavigationSampleLog = function (message) {
'use strict';
var list = document.getElementById('navigationEventLog');
if (!list) { return; }
var item = document.createElement('li');
item.textContent = new Date().toLocaleTimeString() + ' - ' + message;
list.insertBefore(item, list.firstChild);
while (list.children.length > 100) { list.removeChild(list.lastChild); }
};
</script>
</div>
}
@section scripts {
<script>
(function (window, document) {
'use strict';
function log(message) {
if (window.NavigationSampleLog) { window.NavigationSampleLog(message); }
}
// Never forward server errors, filenames, paths or file contents to the shared log.
window.NavigationFileManager = {
onSelect: function (items) { log('Selection count: ' + items.length); },
onSuccess: function () { log('Operation completed.'); },
onFailure: function () { log('Operation failed; details omitted.'); },
cancelOpen: function () { log('File opening cancelled.'); return false; },
// Custom thumbnails: PDF files get an icon of the page's own (the class is styled by the sample).
onFileLoad: function (args) {
if (args.module !== 'NavigationPane' && args.item.type === '.pdf') { args.element.classList.add('fm-custom-pdf'); }
}
};
document.querySelectorAll('.navigation-sample [data-filemanager-api]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('navigationFileManager');
if (!control) { log('Control not ready.'); return; }
var operation = this.getAttribute('data-filemanager-api');
var pending;
if (operation === 'folder') { pending = control.openFolder('/Documents/Reports'); }
if (operation === 'refresh') { pending = control.refresh(); }
if (operation === 'inspect') {
log('Folder available: ' + Boolean(control.getPath()) + '; selection count: ' + control.getSelected().length);
}
if (operation === 'view') {
control.setView(control.getView() === 'details' ? 'largeicons' : 'details');
log('View changed.');
}
if (pending && pending.catch) { pending.catch(function () { log('API request failed; details omitted.'); }); }
});
});
document.querySelectorAll('.navigation-sample [data-filemanager-flat]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('fmFlat');
var data = control && control.getFileSystemData();
log(data ? 'The list holds ' + data.length + ' items.' : 'Control not ready.');
});
});
document.querySelectorAll('.navigation-sample [data-filemanager-virtual]').forEach(function (button) {
button.addEventListener('click', function () {
var control = window.Lumen.get('fmVirtual');
if (control) { control.setView(control.getView() === 'details' ? 'largeicons' : 'details'); log('View changed.'); }
});
});
var picker = document.getElementById('fileManagerTheme');
if (picker) {
picker.addEventListener('change', function () {
var control = window.Lumen.get('navigationFileManager');
if (control) { control.setTheme(this.value); log('Instance theme changed.'); }
});
}
})(window, document);
</script>
}
// This sample uses local data: no controller action is needed.
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
@* Controls with a DataUrl: @Html.AntiForgeryToken() on the page and [HttpPost, ValidateJsonAntiForgeryToken] on the action. *@
The File Manager component is used to manage the files and folders in a file system. It supports all the basic file operations such as create, rename, delete, cut, copy, paste, upload, download, and more.
To load a folder data as list of objects, use the File Manager component FileSystemData property.