页面添加内容后弹出框与跳转页面

Posted on 2013-08-23 14:46  !sylar  阅读(562)  评论(0编辑  收藏  举报
     [HttpPost]
        public ActionResult Form(NewsModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Id == 0)
                {
                    cmd.Add(model);
                }
                else
                {
                    cmd.Update(model.Id, model);
                }
                ViewBag.Msg = "添加成功!";
                ViewBag.ReturnUrl = "/News/List";
            }
            return View();
        }
 <script type="text/javascript">
        $(document).ready(function () {
            if ('@ViewBag.Msg' != null && '@ViewBag.Msg' != "") {
                if (confirm('@ViewBag.Msg' + ',是否继续添加')) {
                        window.location.href = 'Form';
                    }
                    else {
                        window.location.href = '@ViewBag.ReturnUrl';
            }
        }
        });

    </script>

需要引JS包