Example of Custom Contents in ASP.NET MVC ProgressBar Control
This sample illustrates a circular progress bar to show progressCompleted event with annotation.
@Html.UiProgressBar(new UiProgressBarOptions { Id = "label-container", Type = UiProgressType.Circular, Width = "160px", Value = 80, Thickness = 8, StartAngle = 180, EndAngle = 180, ContentTemplate = "#labelTemplate", Label = "Label" })
@Html.UiProgressBar(new UiProgressBarOptions { Id = "pause-container", Type = UiProgressType.Circular, Width = "160px", Value = 100, Thickness = 8, ContentTemplate = "#pauseTemplate", Label = "Pause" })
@Html.UiProgressBar(new UiProgressBarOptions { Id = "download-container", Type = UiProgressType.Circular, Width = "160px", Value = 100, Thickness = 8, ContentTemplate = "#downloadTemplate", Label = "Download" })
@Html.UiButton(new UiButtonOptions { Id = "reLoad", Text = "Reload", Variant = UiButtonVariant.Outline, Color = UiButtonColor.Primary })
<style>
.pb-wrap { max-width: 760px; margin: 0 auto; padding: 20px 0; }
.pb-label { margin: 18px 0 6px; font-size: 14px; font-weight: 500; }
.pb-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; padding: 20px 0; }
.pb-row figure { margin: 0; text-align: center; }
.pb-row figcaption { margin-top: 8px; font-size: 13px; }
.pb-center { text-align: center; padding: 16px 0; }
.annotaion-pro { font-size: 20px; font-weight: 700; }
.pb-icon { display: block; width: 36px; height: 36px; background: var(--ui-accent); }
.pb-pause { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E") center / contain no-repeat; }
.pb-download { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E") center / contain no-repeat; }
</style>
<template id="labelTemplate"><div class="annotaion-pro"><span data-ui-progress-value></span></div></template>
<template id="pauseTemplate"><span class="pb-icon pb-pause" aria-hidden="true"></span></template>
<template id="downloadTemplate"><span class="pb-icon pb-download" aria-hidden="true"></span></template>
<div class="control-section">
<div class="pb-row">
<figure>@Html.UiProgressBar(new UiProgressBarOptions { Id = "label-container", Type = UiProgressType.Circular, Width = "160px", Value = 80, Thickness = 8, StartAngle = 180, EndAngle = 180, ContentTemplate = "#labelTemplate", Label = "Label" })<figcaption>Label</figcaption></figure>
<figure>@Html.UiProgressBar(new UiProgressBarOptions { Id = "pause-container", Type = UiProgressType.Circular, Width = "160px", Value = 100, Thickness = 8, ContentTemplate = "#pauseTemplate", Label = "Pause" })<figcaption>Pause</figcaption></figure>
<figure>@Html.UiProgressBar(new UiProgressBarOptions { Id = "download-container", Type = UiProgressType.Circular, Width = "160px", Value = 100, Thickness = 8, ContentTemplate = "#downloadTemplate", Label = "Download" })<figcaption>Download</figcaption></figure>
</div>
<div class="pb-center">@Html.UiButton(new UiButtonOptions { Id = "reLoad", Text = "Reload", Variant = UiButtonVariant.Outline, Color = UiButtonColor.Primary })</div>
</div>
<script>
// Syncfusion: Reload draws the bars again from the start
var values = [80,100,100];
document.getElementById('reLoad').addEventListener('click', function () {
["label-container","pause-container","download-container"].forEach(function (id, i) {
var bar = window.Lumen.get(id);
bar.setValue(0);
setTimeout(function () { bar.setValue(values[i]); }, 60);
});
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class ProgressBarController : Controller
{
// The page is Views/ProgressBar/Custom.cshtml; it draws what ViewData holds.
public ActionResult Custom()
{
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>
This demo for Essential JS2 Progress Bar control shows the progress bar with custom content with the help of annotation.