Example of Select all and indeterminate state in ASP.NET MVC CheckBox Control
Parent/child checks, array-shaped native fields, label position, sizes and disabled states; no POST endpoint.
Local demo only: use synthetic text, dummy codes/files and scribbles. Do not enter real passwords, personal details or signatures. No new submission endpoint is provided. Event logs contain actions/state only, never field contents.
<div class="input-stack">
<div>@Html.UiCheckBox("all", false, new UiCheckBoxOptions { Id = "checkAll", Label = "Select all", Indeterminate = true, OnChange = "InputChecks.all" })</div>
<div>@Html.UiCheckBox("choices", true, new UiCheckBoxOptions { Id = "checkOne", Value = "one", Label = "One", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("choices", false, new UiCheckBoxOptions { Id = "checkTwo", Value = "two", Label = "Two", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("choices", false, new UiCheckBoxOptions { Id = "checkThree", Value = "three", Label = "Three", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("before", true, new UiCheckBoxOptions { Label = "Label before", LabelPosition = UiLabelPosition.Before, Size = UiInputSize.Small })</div>
<div>@Html.UiCheckBox("large", true, new UiCheckBoxOptions { Label = "Large", Size = UiInputSize.Large })</div>
<div>@Html.UiCheckBox("disabled", true, new UiCheckBoxOptions { Label = "Disabled", Enabled = false })</div>
</div>
@section scripts {
<script>
(function (window) {
'use strict';
var ids = ['checkOne', 'checkTwo', 'checkThree'];
window.InputChecks = {
all: function (checked) {
ids.forEach(function (id) { window.Lumen.get(id).setChecked(checked); });
window.InputSampleLog('Select-all changed');
},
item: function () {
var count = ids.filter(function (id) { return window.Lumen.get(id).isChecked(); }).length;
var all = window.Lumen.get('checkAll');
all.setChecked(count === ids.length);
all.setIndeterminate(count > 0 && count < ids.length);
window.InputSampleLog('Selection count: ' + count);
}
};
})(window);
</script>
}
<div class="input-sample">
<style>
.input-sample .input-row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.input-sample .input-row > .ui-input-control { flex: 1 1 220px; }
.input-sample .input-stack { display: grid; gap: 18px; max-width: 660px; }
.input-sample .input-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.input-sample .input-actions button { padding: 6px 12px; border: 1px solid var(--ui-border); border-radius: 4px; }
.input-sample .ui-slider { margin: 36px 16px; }
.input-sample .input-log { max-height: 180px; overflow: auto; font: 12px monospace; padding: 12px 28px; border: 1px solid var(--ui-border); }
.input-sample .input-drop { padding: 24px; border: 2px dashed var(--ui-border); }
</style>
<p class="small">Local demo only: use synthetic text, dummy codes/files and scribbles. Do not enter real passwords, personal details or signatures. No new submission endpoint is provided. Event logs contain actions/state only, never field contents.</p>
<div class="input-stack">
<div>@Html.UiCheckBox("all", false, new UiCheckBoxOptions { Id = "checkAll", Label = "Select all", Indeterminate = true, OnChange = "InputChecks.all" })</div>
<div>@Html.UiCheckBox("choices", true, new UiCheckBoxOptions { Id = "checkOne", Value = "one", Label = "One", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("choices", false, new UiCheckBoxOptions { Id = "checkTwo", Value = "two", Label = "Two", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("choices", false, new UiCheckBoxOptions { Id = "checkThree", Value = "three", Label = "Three", OnChange = "InputChecks.item" })</div>
<div>@Html.UiCheckBox("before", true, new UiCheckBoxOptions { Label = "Label before", LabelPosition = UiLabelPosition.Before, Size = UiInputSize.Small })</div>
<div>@Html.UiCheckBox("large", true, new UiCheckBoxOptions { Label = "Large", Size = UiInputSize.Large })</div>
<div>@Html.UiCheckBox("disabled", true, new UiCheckBoxOptions { Label = "Disabled", Enabled = false })</div>
</div>
</div>
@section below {
<div class="input-sample">
<h3 class="h6 mt-3">Event log (actions only)</h3>
<ul id="inputEventLog" class="input-log" aria-live="polite"></ul>
<script>
(function (window, document) {
'use strict';
window.InputSampleLog = function (message) {
var list = document.getElementById('inputEventLog');
if (!list) { return; }
var item = document.createElement('li');
item.textContent = message;
list.insertBefore(item, list.firstChild);
while (list.children.length > 30) { list.removeChild(list.lastChild); }
};
})(window, document);
</script>
</div>
}
@section scripts {
<script>
(function (window) {
'use strict';
var ids = ['checkOne', 'checkTwo', 'checkThree'];
window.InputChecks = {
all: function (checked) {
ids.forEach(function (id) { window.Lumen.get(id).setChecked(checked); });
window.InputSampleLog('Select-all changed');
},
item: function () {
var count = ids.filter(function (id) { return window.Lumen.get(id).isChecked(); }).length;
var all = window.Lumen.get('checkAll');
all.setChecked(count === ids.length);
all.setIndeterminate(count > 0 && count < ids.length);
window.InputSampleLog('Selection count: ' + count);
}
};
})(window);
</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. *@