Example of Default Functionalities in ASP.NET MVC Signature Control
This sample demonstrates the basic rendering of the Signature control with the save and clear option.
Sign below
@Html.UiButton(new UiButtonOptions { Id = "signsave", Text = "SAVE", Color = UiButtonColor.Primary, Disabled = true })
@Html.UiButton(new UiButtonOptions { Id = "signclear", Text = "CLEAR", Color = UiButtonColor.Primary, Disabled = true })
@Html.UiSignature("signature", new UiSignatureOptions { Height = "250px", OnChange = "Change" })
<style>
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.property-section .prop-input { width: 90px; padding: 4px 6px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
#signature-control { max-width: 600px; margin: 0 auto; padding: 20px 0; }
.e-sign-heading { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; font-weight: 600; }
.e-btn-options { display: inline-flex; gap: 8px; }
</style>
<div class="control-section">
<div class="content-wrapper">
<div id="signature-control">
<div class="e-sign-heading">
<span id="signdescription">Sign below</span>
<span class="e-btn-options">
@Html.UiButton(new UiButtonOptions { Id = "signsave", Text = "SAVE", Color = UiButtonColor.Primary, Disabled = true })
@Html.UiButton(new UiButtonOptions { Id = "signclear", Text = "CLEAR", Color = UiButtonColor.Primary, Disabled = true })
</span>
</div>
@Html.UiSignature("signature", new UiSignatureOptions { Height = "250px", OnChange = "Change" })
</div>
</div>
</div>
<script>
// Syncfusion: Save and Clear wait until something is drawn; Save downloads the picture, Clear wipes the pad
function pad() { return window.Lumen.get('signature'); }
function setEnabled(id, on) { var b = document.getElementById(id); if (b) { b.disabled = !on; } }
function Change() { var on = !pad().isEmpty(); setEnabled('signsave', on); setEnabled('signclear', on); }
document.addEventListener('click', function (e) {
var button = e.target.closest ? e.target.closest('#signsave, #signclear') : null;
if (!button || button.disabled) { return; }
if (button.id === 'signsave') { pad().save('png', 'Signature'); }
else { pad().clear(); Change(); }
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class SignatureController : Controller
{
// The page is Views/Signature/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>
The Signature control is a user interface to draw the signature digitally. The Signature control is displayed as a container where end-user can sign their name as a verified signature inside the container.
In this sample, you can draw the signature. Use the Save button to store your signature as an image file, and the Clear button to clear the signature.