Example of Variants in ASP.NET MVC Message Control
This sample demonstrates the predefined appearance variants for the ASP.NET MVC Message control.
Filled
Outlined
Text
@Html.UiMessage(new UiMessageOptions { Id = "msg-default_filled", Severity = UiSeverity.Default, Content = "Editing is restricted", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info_filled", Severity = UiSeverity.Info, Content = "Please read the comments carefully", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success_filled", Severity = UiSeverity.Success, Content = "Your message has been sent successfully", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning_filled", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error_filled", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-default_outlined", Severity = UiSeverity.Default, Content = "Editing is restricted", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info_outlined", Severity = UiSeverity.Info, Content = "Please read the comments carefully", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success_outlined", Severity = UiSeverity.Success, Content = "Your message has been sent successfully", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning_outlined", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error_outlined", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-default", Severity = UiSeverity.Default, Content = "Editing is restricted" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info", Severity = UiSeverity.Info, Content = "Please read the comments carefully" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success", Severity = UiSeverity.Success, Content = "Your message has been sent successfully" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data" })
<style>
.msg-content-section { margin: 0 auto; max-width: 520px; padding-top: 10px; }
.msg-content-section .ui-message { margin: 10px 0; }
.msg-content-section h4 { margin: 12px 0 4px; font-size: 14px; }
.msg-hidden { display: none; }
.property-section .property-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.msg-variants { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.msg-variants .msg-content-section { flex: 1 1 280px; margin: 0; }
</style>
<div class="control-section msg-variant-section">
<div class="msg-variants">
<div class="msg-content-section">
<h4>Filled</h4>
@Html.UiMessage(new UiMessageOptions { Id = "msg-default_filled", Severity = UiSeverity.Default, Content = "Editing is restricted", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info_filled", Severity = UiSeverity.Info, Content = "Please read the comments carefully", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success_filled", Severity = UiSeverity.Success, Content = "Your message has been sent successfully", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning_filled", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection", Variant = UiMessageVariant.Filled })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error_filled", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data", Variant = UiMessageVariant.Filled })
</div>
<div class="msg-content-section">
<h4>Outlined</h4>
@Html.UiMessage(new UiMessageOptions { Id = "msg-default_outlined", Severity = UiSeverity.Default, Content = "Editing is restricted", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info_outlined", Severity = UiSeverity.Info, Content = "Please read the comments carefully", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success_outlined", Severity = UiSeverity.Success, Content = "Your message has been sent successfully", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning_outlined", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection", Variant = UiMessageVariant.Outlined })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error_outlined", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data", Variant = UiMessageVariant.Outlined })
</div>
<div class="msg-content-section">
<h4>Text</h4>
@Html.UiMessage(new UiMessageOptions { Id = "msg-default", Severity = UiSeverity.Default, Content = "Editing is restricted" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-info", Severity = UiSeverity.Info, Content = "Please read the comments carefully" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-success", Severity = UiSeverity.Success, Content = "Your message has been sent successfully" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-warning", Severity = UiSeverity.Warning, Content = "There was a problem with your network connection" })
@Html.UiMessage(new UiMessageOptions { Id = "msg-error", Severity = UiSeverity.Error, Content = "A problem occurred while submitting your data" })
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class MessageController : Controller
{
// The page is Views/Message/Variants.cshtml; it draws what ViewData holds.
public ActionResult Variants()
{
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 Message control can be displayed with predefined appearance variants. The available variants are Text, Outlined and Filled. The default variant type is Text.
- Text - The severity is differentiated using a text color and a light background color.
- Outlined - The severity is differentiated using a text color and a border without background.
- Filled - The severity is differentiated using a text color and a dark background color.
In this sample, messages are displayed with different appearances based on the Variant property.