Example of Default Functionalities in ASP.NET MVC PredefinedDialogs Control
This example demonstrates the usage of dialog utility to display various forms of dialog, including alert, confirm and prompt dialog. Three buttons have been added to this example, click one of them to open the relevant dialog box.
@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; }
</style>
<div id="predefinedDialogDefault" 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: DialogUtility.alert, confirm and confirm with an input; here Lumen.alert, confirm and prompt answer when the dialog closes
document.addEventListener('click', function (e) {
if (e.target.closest('#alertBtn')) {
say('');
window.Lumen.alert({ title: 'Low Battery', content: '10% of battery remaining' }).then(function () { say('The user closed the Alert dialog.'); });
} else if (e.target.closest('#confirmBtn')) {
say('');
window.Lumen.confirm({ title: ' Delete Multiple Items', content: 'Are you sure you want to permanently delete these items?' }).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.prompt({ title: 'Join Chat Group', content: 'Enter your name: ', placeholder: 'Type here..' }).then(function (value) {
say(value === null ? 'The user canceled the prompt dialog' : 'The user\'s input is returned as ' + value);
});
}
});
</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/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 predefined dialogs are used to display messages and collect user input within a web page. The following are the three types of Dialogs:
Alert- Used to show errors, warnings, and information that need user awareness.Confirm- Used to get approval from user that appears before any critical action.Prompt- Used to get input from the user.
See also
- Getting started with predefined dialogs