Jquery 更新网页后显示弹出屏幕
目标: 当我更新或添加新数据时,我希望更新网页,然后会自动出现一个弹出屏幕。文本是“测试” 问题是我不知道怎么做 是否可以使用引导而不是twitter引导来实现这一点 今天,我使用boostrap和asp.NETMVCJquery 更新网页后显示弹出屏幕,jquery,html,css,asp.net-mvc,twitter-bootstrap,Jquery,Html,Css,Asp.net Mvc,Twitter Bootstrap,目标: 当我更新或添加新数据时,我希望更新网页,然后会自动出现一个弹出屏幕。文本是“测试” 问题是我不知道怎么做 是否可以使用引导而不是twitter引导来实现这一点 今天,我使用boostrap和asp.NETMVC 您需要通过一个新的请求将消息持久化到服务器上,这可以通过多种方式实现。您可以使用tempdata、session、DB,或者手动将其传递给操作。我通常使用tempdata,它类似于ViewBag,但会持续到另一个请求: public ActionResult Contact()
您需要通过一个新的请求将消息持久化到服务器上,这可以通过多种方式实现。您可以使用tempdata、session、DB,或者手动将其传递给操作。我通常使用tempdata,它类似于ViewBag,但会持续到另一个请求:
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
TempData["Product"] = "Test";
return View();
}
他认为:
@if (TempData["Product"] != null)
{
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
@TempData["Product"]
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script>$('#myModal').modal();</script>
}
@if(TempData[“产品”!=null)
{
&时代;
情态标题
@TempData[“产品”]
接近
保存更改
$('#myModal').modal();
}
此示例代码查看是否有消息,如果有,它会将模式HTML放在包含消息的页面上。还有其他方法可以做到这一点
在这个小脚本运行之前,请确保页面上引用了引导CSS和JS文件。如何添加和更新数据?AJAX?当您完成更新和添加数据时,它发生在后端内部。需要使用带有消息“Test”的弹出窗口向用户发送消息。感谢您的帮助!
@if (TempData["Product"] != null)
{
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
@TempData["Product"]
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script>$('#myModal').modal();</script>
}