我正在向服务器提交表单,如果一切正常,我想为用户显示某种确认消息.
问题是我正在使用ASP.NET MVC 4我可以做到的地方:
@if (ViewBag.ConfirmMessage != null)
{
<p>@ViewBag.ConfirmNMessage</p>
}
Run Code Online (Sandbox Code Playgroud)
但这样消息仍然存在,我认为这会让用户感到困惑.如果我使用类似的东西:
@if (ViewBag.ConfirmMessage != null)
{
<script>
alert("Some message");
</script>
}
Run Code Online (Sandbox Code Playgroud)
但首先alert与显示一个段落的工作方式不同,而且ViewBag.ConfirmMessage已经有我要显示的消息,将来如果我显示消息而ViewBag.ConfirmMessage不是在每个视图中写一些消息,它将更易于维护.
所以我的问题是<p>@ViewBag.ConfirmNMessage</p>,X如果显示,我可以在几秒钟后隐藏起来?
@if (ViewBag.ConfirmMessage != null)
{
<p id="confirmMsg">@ViewBag.ConfirmNMessage</p>
}
Run Code Online (Sandbox Code Playgroud)
和
@if (ViewBag.ConfirmMessage != null)
{
<script>
setTimeout(function() {
$('#confirmMsg').hide();
}, X * 1000);
</script>
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1814 次 |
| 最近记录: |