Skip to content

Commit 32965b0

Browse files
Create an Alert system to show alerts on UI for MVC applications
1 parent a0d2bee commit 32965b0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/AbpCompanyName.AbpProjectName.WebMpa/Views/Shared/_Layout.cshtml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
@using System.Web.Optimization
33
@using Abp.Configuration
44
@using Abp.Timing
5-
@using Abp.Web.Mvc.Extensions
65
@using AbpCompanyName.AbpProjectName
76
@using AbpCompanyName.AbpProjectName.Configuration
7+
@using Abp.Dependency
8+
@using Abp.Web.Mvc.Alerts
89
@{
910
Layout = null;
1011
SetAntiForgeryCookie();
1112
var uiTheme = SettingManager.GetSettingValue(AppSettingNames.UiTheme);
13+
AlertList alerts = null;
14+
IocManager.Instance.Using<IAlertManager>(alertManager => alerts = alertManager.Alerts);
1215
}
1316
<!DOCTYPE html>
1417
<html lang="en">
@@ -110,6 +113,25 @@
110113

111114
<section class="content">
112115
<div class="container-fluid">
116+
@if (alerts.Any())
117+
{
118+
<div id="AbpPageAlerts">
119+
@foreach (var alertMessage in alerts)
120+
{
121+
<div class="alert [email protected]().ToLower() @(alertMessage.Dismissible ? "alert-dismisable" : "")" role="alert">
122+
<h4 class="alert-heading">
123+
@alertMessage.Title
124+
@if (alertMessage.Dismissible)
125+
{
126+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
127+
}
128+
</h4>
129+
<p>@alertMessage.Text</p>
130+
</div>
131+
}
132+
</div>
133+
}
134+
113135
@RenderBody()
114136
</div>
115137
</section>

0 commit comments

Comments
 (0)