Example of Ticks in ASP.NET MVC Slider Control
This sample demonstrates the default rendering of Slider component. Drag the thumb over the bar for selecting the values between min and max.
Placement
Disabled
@Html.UiSlider("default", new UiSliderOptions { Min = 0.1, Max = 0.9, Value = 0.3, Step = 0.05, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 0.2, SmallStep = 0.05, ShowSmallTicks = true } })
@Html.UiSlider("range", new UiSliderOptions { Min = 0, Max = 100, Step = 5, Values = (double[])ViewData["sliderValue"], Type = UiSliderType.Range, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true } })
@Html.UiDropDownList("placement", new UiDropDownListOptions { Width = "110px", Value = "Before", OnChange = "dropDownChange", Items = ((IEnumerable<InputsDemoController.SliderChoice>)ViewData["dataSource"]).Select(c => new UiListItem(c.id, c.text)).ToList() })
@Html.UiCheckBox("checked", false, new UiCheckBoxOptions { Id = "checked", OnChange = "onChange" })
<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>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div class="control-wrapper">
<div class="sliderwrap">
<label class="userselect">Default Slider</label>
@Html.UiSlider("default", new UiSliderOptions { Min = 0.1, Max = 0.9, Value = 0.3, Step = 0.05, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 0.2, SmallStep = 0.05, ShowSmallTicks = true } })
</div>
<div class="sliderwrap">
<label class="userselect">Range Slider</label>
@Html.UiSlider("range", new UiSliderOptions { Min = 0, Max = 100, Step = 5, Values = (double[])ViewData["sliderValue"], Type = UiSliderType.Range, Ticks = new UiSliderTicks { Placement = UiSliderPlacement.Before, LargeStep = 20, SmallStep = 5, ShowSmallTicks = true } })
</div>
</div>
</div>
<div class="demo-property-panel property-section" title="Properties">
<div class="property-row"><span>Placement</span> @Html.UiDropDownList("placement", new UiDropDownListOptions { Width = "110px", Value = "Before", OnChange = "dropDownChange", Items = ((IEnumerable<InputsDemoController.SliderChoice>)ViewData["dataSource"]).Select(c => new UiListItem(c.id, c.text)).ToList() })</div>
<div class="property-row"><span>Disabled</span> @Html.UiCheckBox("checked", false, new UiCheckBoxOptions { Id = "checked", OnChange = "onChange" })</div>
</div>
<script>
// Syncfusion: the list sets the placement of the ticks of both sliders, the check box disables them
function sliders() { return [window.Lumen.get('default'), window.Lumen.get('range')]; }
function onChange(checked) { sliders().forEach(function (s) { s[checked ? 'disable' : 'enable'](); }); }
function dropDownChange(value) { if (value) { sliders().forEach(function (s) { s.setTicks({ placement: value }); }); } }
</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/Ticks.cshtml; it draws what ViewData holds.
public ActionResult Ticks()
{
ViewData["sliderValue"] = new double[] { 30, 70 };
ViewData["dataSource"] = new List<SliderChoice> { new SliderChoice("Before", "Before"), new SliderChoice("After", "After"), new SliderChoice("Both", "Both"), new SliderChoice("None", "None") };
return View();
}
public class SliderChoice
{
public string text { get; set; }
public string id { get; set; }
public SliderChoice(string text, string id) { this.text = text; this.id = id; }
}
}
}
@* 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 Slider component allows the user to select a value or range of values in-between a min and max range, by dragging the thumb over the slider bar. There are three types of sliders available: