我从控制器收集数据并将其放入名为:message的会话变量中。然后,我将消息传递给关联的cshtml(Razor)页面,并将其传递给具有alert-success类的div。我遇到的问题是不知道如何在单击保存按钮时切换消息。附上剃刀代码。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<p id="divConfirmationMessage" class="success-message message no-display">
<span style="width:50px;" class="fl">
<span class="icon successGreen"></span>
<div class="alert alert-success"><span> @Session["message"]</span></div>
</span>
<span class="icon close" style="padding-left:20px" id="spnReserveAcctCloseIcon"></span>
</p>
&#13;
答案 0 :(得分:0)
使用Razor的@if条件
@if (@Session["message"] != null)
{
<p id="divConfirmationMessage" class="success-message message no-display">
<span style="width:50px;" class="fl">
<span class="icon successGreen"></span>
<div class="alert alert-success"><span>@Session["message"]</span></div>
</span>
<span class="icon close" style="padding-left:20px" id="spnReserveAcctCloseIcon"></span>
</p>
}