Example of Default Functionalities in ASP.NET MVC Message Control
This sample demonstrates the default functionalities of the ASP.NET MVC Message control with different severity types and predefined styles.
@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; }
</style>
<div class="control-section msg-default-section">
<div class="msg-content-section">
@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>
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/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 Message control displays messages with different severity levels, set with icons and colors to denote the importance and context of the message to the end user.
The available severity messages are Normal, Success, Info, Warning and Error.
- Normal - The message is displayed with an icon and color to denote it as a normal message.
- Success - The message is displayed with an icon and color to denote it as a success message.
- Info - The message is displayed with an icon and color to denote it as information.
- Warning - The message is displayed with an icon and color to denote it as a warning message.
- Error - The message is displayed with an icon and color to denote it as an error message.
In this sample, messages are displayed with a distinct icon and a color based on the Content and Severity properties.