Example of Limits in ASP.NET MVC Slider Control
This sample demonstrates the rendering of Slider component with limits. Drag the thumb over the bar for selecting the values between assigned limit values. Change the values in the property pane to set different limit values.
MinStart
MinEnd
MaxStart
MaxEnd
Lock First Handle
Lock Second Handle
@Html.UiSlider("minrange", new UiSliderOptions { Min = 0, Max = 100, Value = 25, Type = UiSliderType.MinRange, Limits = new UiSliderLimits { Enabled = true, MinStart = 10, MinEnd = 40 }, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true }, Tooltip = new UiSliderTooltip { IsVisible = true, Placement = UiSliderPlacement.After, ShowOn = UiSliderTooltipShowOn.Always } })
@Html.UiSlider("range", new UiSliderOptions { Min = 0, Max = 100, Values = (double[])ViewData["rangeValue"], Type = UiSliderType.Range, Limits = new UiSliderLimits { Enabled = true, MinStart = 10, MinEnd = 40, MaxStart = 60, MaxEnd = 90 }, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true }, Tooltip = new UiSliderTooltip { IsVisible = true, Placement = UiSliderPlacement.After, ShowOn = UiSliderTooltipShowOn.Always } })
@Html.UiNumericTextBox("minStart", new UiNumericTextBoxOptions { Value = 10, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "minStartChange" })
@Html.UiNumericTextBox("minEnd", new UiNumericTextBoxOptions { Value = 40, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "minEndChange" })
@Html.UiNumericTextBox("maxStart", new UiNumericTextBoxOptions { Value = 60, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "maxStartChange" })
@Html.UiNumericTextBox("maxEnd", new UiNumericTextBoxOptions { Value = 90, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "maxEndChange" })
@Html.UiCheckBox("fixedOne", false, new UiCheckBoxOptions { Id = "fixedOne", OnChange = "fixOne" })
@Html.UiCheckBox("fixedSecond", false, new UiCheckBoxOptions { Id = "fixedSecond", OnChange = "fixSecond" })
<style>
.control-section .control-wrapper { width: 80%; margin: 0 auto; min-width: 185px; }
.sliderwrap { margin-top: 40px; }
.sliderwrap label, .slider-labeltext { display: block; padding-bottom: 14px; font-size: 13px; font-weight: 500; user-select: none; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
</style>
<div class="control-section">
<div class="content-wrapper">
<div class="sliderwrap">
<label class="userselect">MinRange Slider With Limits</label>
@Html.UiSlider("minrange", new UiSliderOptions { Min = 0, Max = 100, Value = 25, Type = UiSliderType.MinRange, Limits = new UiSliderLimits { Enabled = true, MinStart = 10, MinEnd = 40 }, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true }, Tooltip = new UiSliderTooltip { IsVisible = true, Placement = UiSliderPlacement.After, ShowOn = UiSliderTooltipShowOn.Always } })
</div>
<div class="sliderwrap">
<label class="userselect">Range Slider With Limits</label>
@Html.UiSlider("range", new UiSliderOptions { Min = 0, Max = 100, Values = (double[])ViewData["rangeValue"], Type = UiSliderType.Range, Limits = new UiSliderLimits { Enabled = true, MinStart = 10, MinEnd = 40, MaxStart = 60, MaxEnd = 90 }, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true }, Tooltip = new UiSliderTooltip { IsVisible = true, Placement = UiSliderPlacement.After, ShowOn = UiSliderTooltipShowOn.Always } })
</div>
</div>
</div>
<div class="demo-property-panel property-section" title="Properties">
<div class="property-row"><span>MinStart</span> @Html.UiNumericTextBox("minStart", new UiNumericTextBoxOptions { Value = 10, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "minStartChange" })</div>
<div class="property-row"><span>MinEnd</span> @Html.UiNumericTextBox("minEnd", new UiNumericTextBoxOptions { Value = 40, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "minEndChange" })</div>
<div class="property-row"><span>MaxStart</span> @Html.UiNumericTextBox("maxStart", new UiNumericTextBoxOptions { Value = 60, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "maxStartChange" })</div>
<div class="property-row"><span>MaxEnd</span> @Html.UiNumericTextBox("maxEnd", new UiNumericTextBoxOptions { Value = 90, Min = 0, Max = 100, Step = 1, Format = "N0", Width = "100px", OnChange = "maxEndChange" })</div>
<div class="property-row"><span>Lock First Handle</span> @Html.UiCheckBox("fixedOne", false, new UiCheckBoxOptions { Id = "fixedOne", OnChange = "fixOne" })</div>
<div class="property-row"><span>Lock Second Handle</span> @Html.UiCheckBox("fixedSecond", false, new UiCheckBoxOptions { Id = "fixedSecond", OnChange = "fixSecond" })</div>
</div>
<script>
// Syncfusion: the panel moves the limits of the handles and locks them
function minrange() { return window.Lumen.get('minrange'); }
function range() { return window.Lumen.get('range'); }
function minStartChange(value) { minrange().setLimits({ minStart: value }); range().setLimits({ minStart: value }); }
function minEndChange(value) { minrange().setLimits({ minEnd: value }); range().setLimits({ minEnd: value }); }
function maxStartChange(value) { range().setLimits({ maxStart: value }); }
function maxEndChange(value) { range().setLimits({ maxEnd: value }); }
function fixOne(checked) { range().setHandleFixed(0, checked); }
function fixSecond(checked) { range().setHandleFixed(1, checked); }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class RangeSliderController : Controller
{
// The page is Views/RangeSlider/Limits.cshtml; it draws what ViewData holds.
public ActionResult Limits()
{
ViewData["rangeValue"] = new double[] { 25, 75 };
return View();
}
}
}
@* 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>
The limits are used to limit between certain range. When the limits are assigned, draggable limited area will be in the dark shadow color of the current theme. The limits APIs are explained below.
| minStart | - Used to set minimum limit value for first handle. |
| minEnd | - Used to set maximum limit value for first handle. |
| maxStart | - Used to set minimum limit value for second handle. |
| maxEnd | - Used to set maximum limit value for first handle. |
| startHandleFixed | - Used to lock the first handle in the current position. |
| endHandleFixed | - Used to lock the second handle in the current position. |
In this demo, Limits with MinRange and range Slider is demonstrated.
- MinRange Slider – In this sample, the minimum and maximum limit of the slider is set to 10 and 40 respectively.
- Range Slider – In this sample, the minimum and maximum limit of the first handle is set to 10 and 40 respectively and the minimum and maximum limit of the second handle is set to 60 and 90 respectively.