在控制器中使用Redirect或者使用RedirectToAction重定向视图,需要弹出提示框情况下是加一个中间单独的跳转页,在跳转页里面弹出提示。实例:
视图代码:
<a role="button" class="btn green" id="judgeAdd" onclick="showJudge_modal()" data-toggle="modal">预约</a> <script> function showJudge_modal() { var url = "/Home/JudgeAppoint"; $("#judgeAdd").attr("href", encodeURI(url)); } </script>
控制器代码:
public ActionResult Index() { return View(); }
public ActionResult JudgeAppoint() { return View(); }
public ActionResult AddJudgeAppoint()
{
return Redirect("rjudge");
}
public ActionResult rjudge()
{
return Content("<script>alert('12121');location.href='/Home/JudgeAppoint'</script>");
}
不过这样处理还有个问题,就是在IE和火狐浏览器上总是先弹出提示框,再呈现试图,体验不好;哪位知道更好的处理方式可否告知,灰常感谢