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