Example of Default Functionalities in ASP.NET MVC Button Control
This sample demonstrates the default functionalities of the Button with different types and predefined styles.
@Html.UiButton(new UiButtonOptions { Id = "primarybtn", Text = "Primary", Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "normalbtn", Text = "Normal" })
@Html.UiButton(new UiButtonOptions { Id = "outlinebtn", Text = "Outline", Color = UiButtonColor.Primary, Variant = UiButtonVariant.Outline })
@Html.UiButton(new UiButtonOptions { Id = "flatbtn", Text = "Flat", Color = UiButtonColor.Primary, Variant = UiButtonVariant.Flat })
@Html.UiButton(new UiButtonOptions { Id = "successbtn", Text = "Success", Color = UiButtonColor.Success })
@Html.UiButton(new UiButtonOptions { Id = "warningbtn", Text = "Warning", Color = UiButtonColor.Warning })
@Html.UiButton(new UiButtonOptions { Id = "dangerbtn", Text = "Danger", Color = UiButtonColor.Danger })
@Html.UiButton(new UiButtonOptions { Id = "infobtn", Text = "Info", Color = UiButtonColor.Info })
@Html.UiButton(new UiButtonOptions { Id = "roundbtn", IconCss = "ui-icon-plus", Title = "Add", Size = UiInputSize.Small, Round = true, Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "togglebtn", Text = "Play", IconCss = "ui-icon-play", Variant = UiButtonVariant.Flat, Color = UiButtonColor.Primary, IsToggle = true, OnClick = "toggleClick" })
@Html.UiButton(new UiButtonOptions { Id = "openiconbtn", Text = "Open", Variant = UiButtonVariant.Flat, Color = UiButtonColor.Primary, IconCss = "ui-icon-open", IconPosition = UiIconPosition.Right })
@Html.UiButton(new UiButtonOptions { Id = "smallbtn", Text = "Small", Size = UiInputSize.Small })
<style>
.button-default-grid { display: grid; grid-template-columns: repeat(4, max-content); justify-content: center; gap: 28px 52px; align-items: center; padding: 28px 0; }
</style>
<div class="control-section">
<div class="button-section">
<div id="button-control" class="button-default-grid">
@Html.UiButton(new UiButtonOptions { Id = "primarybtn", Text = "Primary", Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "normalbtn", Text = "Normal" })
@Html.UiButton(new UiButtonOptions { Id = "outlinebtn", Text = "Outline", Color = UiButtonColor.Primary, Variant = UiButtonVariant.Outline })
@Html.UiButton(new UiButtonOptions { Id = "flatbtn", Text = "Flat", Color = UiButtonColor.Primary, Variant = UiButtonVariant.Flat })
@Html.UiButton(new UiButtonOptions { Id = "successbtn", Text = "Success", Color = UiButtonColor.Success })
@Html.UiButton(new UiButtonOptions { Id = "warningbtn", Text = "Warning", Color = UiButtonColor.Warning })
@Html.UiButton(new UiButtonOptions { Id = "dangerbtn", Text = "Danger", Color = UiButtonColor.Danger })
@Html.UiButton(new UiButtonOptions { Id = "infobtn", Text = "Info", Color = UiButtonColor.Info })
@Html.UiButton(new UiButtonOptions { Id = "roundbtn", IconCss = "ui-icon-plus", Title = "Add", Size = UiInputSize.Small, Round = true, Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "togglebtn", Text = "Play", IconCss = "ui-icon-play", Variant = UiButtonVariant.Flat, Color = UiButtonColor.Primary, IsToggle = true, OnClick = "toggleClick" })
@Html.UiButton(new UiButtonOptions { Id = "openiconbtn", Text = "Open", Variant = UiButtonVariant.Flat, Color = UiButtonColor.Primary, IconCss = "ui-icon-open", IconPosition = UiIconPosition.Right })
@Html.UiButton(new UiButtonOptions { Id = "smallbtn", Text = "Small", Size = UiInputSize.Small })
</div>
</div>
</div>
<script>
// Syncfusion: the toggle button says Pause (and shows its icon) while it is pressed.
function toggleClick(id, pressed) {
window.Lumen.get('togglebtn').setContent(pressed ? 'Pause' : 'Play', pressed ? 'ui-icon-pause' : 'ui-icon-play');
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class ButtonController : Controller
{
// The page is Views/Button/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
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>
Button is a graphical user interface element that triggers an event on click action. It contains the text, an image, or both.
In this sample, Play button is a toggle button and it can be enabled by using the isToggle property. To change the text and icon you should handle click event.