Example of Customization in ASP.NET MVC PredefinedDialogs Control
This example demonstrates how to customize the content of the predefined Alert, Confirm and Prompt dialogs. Three buttons have been added to this example, click one of them to open the relevant dialog box.
Good job!
You clicked the button!
Are you sure you want to permanently delete this file?
failed personas.png
Item type:PNG File
Dimenstion: 1384 * 782
Size:374 KB
Original Location: C:/Users/Images
| SSID: AndroidAP |
| Password: |
@Html.UiButton(new UiButtonOptions { Id = "alertBtn", Text = "Alert", Color = UiButtonColor.Warning })
@Html.UiButton(new UiButtonOptions { Id = "confirmBtn", Text = "Confirm", Color = UiButtonColor.Success })
@Html.UiButton(new UiButtonOptions { Id = "promptBtn", Text = "Prompt", Color = UiButtonColor.Primary })
<style>
.control-section { padding: 25px 0 0 15px; min-height: 250px; }
.control-section #statusText { display: block; font-size: 16px; margin-top: 20px; }
.control-section .ui-btn { margin-right: 5px; }
.circle-border { display: inline-flex; width: 56px; height: 56px; align-items: center; justify-content: center; border: 2px solid green; border-radius: 50%; }
.fileEdit { display: flex; gap: 10px; align-items: center; }
.wifi-input { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
</style>
<template id="alertTemplate"><div class="new" style="display: flex; flex-direction: column; align-items: center;"><p><span class="circle-border"><span class="e-icons e-check" style="font-size: 30px; color: green;"></span></span></p><p><b style="font-size: 25px; font-weight: 500;">Good job!</b></p><p>You clicked the button!</p></div></template>
<template id="deleteTemplate"><p><span class="e-icons e-changes-reject" style="float: left; padding-right: 10px; font-size: 25px;"></span>Are you sure you want to permanently delete this file?</p><p class="fileEdit"><span class="e-icons e-image" style="font-size: 50px;"></span><span>failed personas.png<br />Item type:PNG File<br />Dimenstion: 1384 * 782<br />Size:374 KB<br />Original Location: C:/Users/Images</span></p></template>
<template id="wifiTemplate"><table class="Table"><tbody><tr><td>SSID: <b>AndroidAP</b></td></tr><tr><td>Password:</td></tr><tr><td><input type="password" id="password" name="Required" class="wifi-input" /></td></tr></tbody></table></template>
<div id="predefinedDialogCustomization" class="control-section">
@Html.UiButton(new UiButtonOptions { Id = "alertBtn", Text = "Alert", Color = UiButtonColor.Warning })
@Html.UiButton(new UiButtonOptions { Id = "confirmBtn", Text = "Confirm", Color = UiButtonColor.Success })
@Html.UiButton(new UiButtonOptions { Id = "promptBtn", Text = "Prompt", Color = UiButtonColor.Primary })
<span id="statusText"></span>
</div>
<script>
function say(text) { document.getElementById('statusText').textContent = text; }
</script>
<script>
// Syncfusion: the dialogs get their own title, texts, width and content
document.addEventListener('click', function (e) {
if (e.target.closest('#alertBtn')) {
say('');
window.Lumen.alert({ title: '', template: '#alertTemplate', okText: 'OK', width: '240px' }).then(function () { say('The user closed the Alert dialog.'); });
} else if (e.target.closest('#confirmBtn')) {
say('');
window.Lumen.confirm({ title: ' Delete file', template: '#deleteTemplate', okText: 'YES', cancelText: 'No', width: '420px' }).then(function (yes) {
say(yes ? ' The user confirmed the dialog box' : 'The user canceled the dialog box.');
});
} else if (e.target.closest('#promptBtn')) {
say('');
window.Lumen.confirm({ title: 'Join Wi-Fi network', template: '#wifiTemplate', okText: 'OK', width: '240px' }).then(function (yes) {
say(yes ? ' The user confirmed the dialog box' : 'The user canceled the prompt dialog');
});
}
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class PredefinedDialogsController : Controller
{
// The page is Views/PredefinedDialogs/Customization.cshtml; it draws what ViewData holds.
public ActionResult Customization()
{
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 predefined dialog is used to display messages such as supplemental content like graphics, text, and interactive content like form components within a web page. It can use the content property to load customized content. The content property accepts both string and HTML elements as content.
See also
- Customization of predefined dialogs